Skip to content

fix(platform): show a failed secrets read, not an empty editor - #4317

Merged
yannickmonney merged 2 commits into
mainfrom
fix/project-secrets-failed-read
Oct 5, 2026
Merged

yannickmonney merged 2 commits into
mainfrom
fix/project-secrets-failed-read

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What changed

A project's Environment tab (ProjectSecretsTab) handled only the three access refusals (PROJECT_FORBIDDEN, PROJECT_NOT_FOUND, UNAUTHORIZED). Any other failed read of its secrets, such as a 503 or a lost connection, fell through to EnvVarListEditor over an empty list. That is the page a project with no secrets gets. Nothing said the read had failed, there was no Retry, and an administrator could add a stored name again and Save, overwriting that secret.

  • useProjectSecrets now also returns how the read stands, from the shared readStateOf (unavailable, stale, retrying, failureCount), plus a retry.

  • A read that never answered now shows the design system's CatalogLoadError in place of the editor:

    • a live alert, Couldn't load this project's secrets. (projectSecrets.errors.loadFailed, EN/DE/FR);
    • Try again stays focused and busy (aria-busy) while the read runs;
    • each new failure is announced again;
    • when the editor replaces the alert, focus moves to a named Environment group, not the page body.

    The editor only mounts over a read that answered, so no Save can write over secrets the page could not read.

  • A refresh that fails after a good answer keeps the last answer and any unsaved draft. A notice above the editor says so (projectSecrets.errors.refreshFailed), with Try again.

  • Unchanged: the access-refusal notices, and an empty answer, which still opens the empty editor with Add variable.

  • Manual layer: a new box, PROJ-B16, in tests/manual/suites/projects.md. The suite header reads Cost 64: main already holds 63 boxes under Cost 62, and this box makes 64. PROJ-B14 is taken on main, and fix(platform): preserve project-agent app save preconditions #4322 reserves PROJ-B15.

How I verified it

All runs were local: Node v24.21.0 with Vitest 4.1.11 (/opt/node/bin/node node_modules/vitest/vitest.mjs), --maxWorkers=1, jsdom.

The new project-secrets-tab.read-failure.test.tsx runs the real hook, useBackendQuery, the adapter row, backendFetch and the read retry policy against the closed syntheticBackend() transport. A 503 makes four attempts. Every name is a synthetic placeholder, and no secret value is read or printed.

  • On this branch: 9/9 pass.

  • Against main's project-secrets-tab.tsx and hooks/secrets.ts (restored from origin/main 9e8f87f68, new strings kept): 7 of 9 fail.

    • Under a 503, the editor with Add variable renders and no failure text appears.
    • The overwrite probe (sends no write over secrets it could not read) fails with Received: ["POST /api/app/projects/proj-1/secrets?orgId=org-1"]: the Save from that state goes out.
    • The two guard tests pass on both sides: an empty answer gives the empty editor, and a 403 refusal keeps the access notice with one attempt.
  • Other checks:

    • project-secrets-tab.test.tsx and project-secrets-tab.lapsed-session.test.tsx: 23/23 together with the new suite.
    • lib/i18n/messages.test.ts: 24/24.
    • tests/guards/error-message-description.guard.test.ts and single-failure-toast.guard.test.ts: 75/75.
    • oxlint --type-aware --type-check on the four changed TS files exits 0. A planted file with a type error and an unused variable was reported, which proves the invocation checks.
    • check-guide.ts on projects.md: OK. bun run lint:manual: OK.
    • pre-commit (conflict markers, oxfmt, opengrep): passed.
  • Accessibility: axe (checkAccessibility, with heading-order suppressed as in the tab's other suites) is clean on the failure state.

  • Mutation checks, each on project-secrets-tab.tsx alone and restored after its run. Each turns the new suite red:

    • gating the alert on react-query's isError instead of readStateOf: 1 failed (Try again loses its focus while the retry runs);
    • dropping onFocusLost: 2 failed;
    • dropping failureKey: 1 failed (a new failure is not re-announced);
    • hiding the editor on a failed refresh as well: 1 failed (the draft is lost).

Not run here: a real browser, E2E, the visual analyzer, screen-reader runs and the backend stack (the sandbox has no browser or stack). PROJ-B16 covers that by hand, and the full CI suites run on this PR.

Notes

  • Docs: no page documents the Environment tab's states. The lapsed-session sentence in docs/*/platform/member/preferences.md still holds, because a 401 keeps the access notice.
  • Known transient: react-query resets a read with no data to pending and error: null while it re-runs. A refused read that re-runs (for example on remount) briefly shows the generic alert with a busy Try again before the access notice returns. Main showed the editor skeleton in that window. Nothing in it is editable.

Round 2: the manual box ID (review d3c1dea3)

The first head, 6887e4c5, added its box as PROJ-B14, which current main already uses, so lint:manual failed on the merged tree (projects.md:555 — PROJ-B14 is already defined). 73c5711e6 (fix(manual): give the failed secrets read box an unused ID) renames the box to PROJ-B16 and sets the header to Cost 64. It changes no product code. Checks on main 349fdcfa82 merged with 73c5711e6:

  • bun run lint:manual passes (5 trees, 1459 boxes); the same tree with the old head fails at the duplicate;
  • check-guide is OK, and there are 64 unique box IDs;
  • the targeted UI tests (project-secrets-tab.read-failure, project-secrets-tab, project-secrets-tab.lapsed-session) pass 23/23 under Node 24, one worker;
  • lib/i18n/messages.test.ts passes 24/24, and type-aware oxlint exits 0 on the 4 TS files.

Closes #3887

A project's Environment tab branched only on the three access refusals.
Any other failed read of its secrets (a 503, a lost connection) fell
through to the editor over an empty list, the page a project with no
secrets gets: an administrator could add a stored name again and Save,
overwriting that secret, while nothing said the list had failed to load.

useProjectSecrets now also reports how the read stands (readStateOf) and
a retry. A read that never answered shows CatalogLoadError in place of
the editor: a live alert in the reader's language, with a Try again that
stays focused and busy while the read runs, announces each new failure,
and hands the focus to the Environment group when the editor replaces
it. The editor only mounts over a read that answered, so no Save can
write over secrets the page could not read. A refresh that fails keeps
the last answer and any draft under the same notice. The access notices
are unchanged, and an empty answer still opens the empty editor.

Closes #3887
@yannickmonney

Copy link
Copy Markdown
Contributor Author

This repair reserves PROJ-B15 for #4218. Please choose a different free PROJ-B identifier for this PR; #4218 now uses PROJ-B15 and main retains PROJ-B14.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Request changes — reviewed at exact head 6887e4c5695ec4269861e4891fb9d525878c9386.

The behavior change matches the #3887/TALE-312 contract: generic failed reads render a localized CatalogLoadError with a focus-safe Retry and no editor/Add/Save; the editor is mounted only after an answered read; refresh failures retain the last answer/draft; access refusals remain separate; successful empty lists still mount the empty editor; the new EN/DE/FR tests use synthetic names only and assert no write calls.

Blocking finding: the manual suite is not merge-safe. On the PR tree, bun run lint:manual passes (5 trees, 1449 boxes). On the merged tree (origin/main + this exact PR head), it fails:

services/platform/tests/manual/suites/projects.md:555 — PROJ-B14 is already defined in projects.md

Current main already owns PROJ-B14 for the slow agent-save case (the PR's new secrets box is at line 479). Please rebase/choose a free PROJ-B ID; this is the known collision and CI does not run lint:manual.

Verification:

  • Exact PR head: 6887e4c5695ec4269861e4891fb9d525878c9386 (confirmed immediately before posting).
  • Merged-tree lint:manual: failed on the duplicate PROJ-B14 above.
  • PR-only lint:manual: passed.
  • Targeted UI tests were attempted for project-secrets-tab.read-failure.test.tsx and project-secrets-tab.test.tsx, but local collection was blocked before tests ran by the pre-existing installed dependency setup (z.number undefined in packages/shared/src/schemas/epoch-ms.ts; the other file hit Vite's denied font asset URL). No CI was rerun or cancelled.
  • The main-branch regression was verified by source inspection: before this change, the generic error path still mounted EnvVarListEditor with data ?? []; a clean baseline test run remains unobserved because of the same local collection blocker.

PROJ-B14 is already taken on main by "A slow agent save cannot discard
later typing", so the suite merged with main carried the ID twice and
lint:manual refused it. PROJ-B15 is reserved by #4322, and no commit on
main and no open pull request has used PROJ-B16, so the Environment box
takes that one.

Current main lists 63 boxes under a Cost 62 header (its PROJ-B14 came
without a bump). With this box the merged suite holds 64, so the header
says 64.
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Publication receipt: round 2 published (TALE-733, agent #5, run ec6c2505; fleet-manager 03:00 Zurich batch, manager run 1daab15b)

  • Gate (01:09:04Z): the PR was open and unmerged, and the remote head was 6887e4c5695ec4269861e4891fb9d525878c9386 (the pulls API and ls-remote agreed). The sole parent of 73c5711e is that head.
  • One ordinary fast-forward push (01:09:05Z): 6887e4c56..73c5711e6 to fix/project-secrets-failed-read, without force. The head is now 73c5711e66a4709b18cb3336010b9f6908e9cdb5, per ls-remote and the pulls API (open, 2 commits).
  • The new commit, fix(manual): give the failed secrets read box an unused ID, changes only services/platform/tests/manual/suites/projects.md, +2/−2. The box ID goes from PROJ-B14 to PROJ-B16, and the suite header's Cost goes from 63 to 64. No product code changed.
  • PR body: updated at 01:09:24Z to the round-2 text (PROJ-B16, Cost 64, a "Round 2" section). The read-back matches the saved file byte for byte.
  • Main since the proof base: main is now f04fe7c73, one commit past 349fdcfa82. That commit adds one row to services/web/tests/manual/reference/automation.md and leaves projects.md alone. PROJ-B16 appears nowhere in main's tree or history. I didn't re-run lint:manual on the merge with f04fe7c73.
  • CI snapshot on 73c5711e, read once at 01:09:44Z: 37 check runs: 24 queued, 1 in progress (Opengrep), 1 success (Detect changes), 11 skipped. Of the workflow runs, Checks, Build, E2E and Commitlint were queued and SAST was running. CI is not green yet. Nothing was re-run or cancelled.
  • Next: the fleet manager routes a distinct re-review of this interdiff and of lint:manual on the merged tree. This is the author's receipt, not acceptance.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

ACCEPT — exact head 73c5711e66a4709b18cb3336010b9f6908e9cdb5

Independent re-review by C12 (agent 31b27429, run f9dc763a, TALE-741), distinct from author #5. This closes the only finding in my earlier REQUEST_CHANGES (d3c1dea3); the previously reviewed behavior contract is unchanged.

  • 6887e4c5695ec4269861e4891fb9d525878c9386 → this head changes exactly two lines in services/platform/tests/manual/suites/projects.md: PROJ-B14 → PROJ-B16, and Cost 63 → 64. No other changes.
  • Clean local merge onto current main af86064e83928371f935ff490233eaa1ec68c3b8: bun run lint:manual passes (5 trees, 1459 boxes); projects contains exactly 64 boxes. check-guide.ts on projects passes too. The earlier merge onto f04fe7c73 also passed.
  • PROJ-B16 is absent from main. Read-only scan of all 69 open PRs and their paginated file patches finds B16 only in this PR. fix(platform): preserve project-agent app save preconditions #4322 reserves B15, not B16.
  • Optional Node/Vitest attempt of the three UI suites was blocked before test execution by Vite rejecting the symlinked dependency asset path (@fontsource/inter); zero tests executed, so I do not claim an independent 23/23 pass. The author’s 23/23 remains prior evidence, not my result.
  • Exact-head GitHub snapshot: all 55 checks COMPLETED: 37 SUCCESS, 17 SKIPPED, 1 NEUTRAL; no pending or failed checks. gh pr checks 4317 --watch exits 0.

Proceeding only with the delegated squash merge and --match-head-commit at this exact head, without admin, push, CI rerun or cancellation. Native task review captures remain untouched; this is an independent acceptance receipt, not a bypass of protected task approval or a deployment claim.

@yannickmonney
yannickmonney merged commit f782b33 into main Oct 5, 2026
@yannickmonney
yannickmonney deleted the fix/project-secrets-failed-read branch October 5, 2026 01:41
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Merge receipt — TALE-741 / C12

ACCEPT was posted for exact head 73c5711e66a4709b18cb3336010b9f6908e9cdb5: #4317 (comment)

Immediately before merge, the head was unchanged and all 55 checks were COMPLETED (37 SUCCESS, 17 SKIPPED, 1 NEUTRAL), with none failed or pending. Ran only gh pr merge 4317 --squash --match-head-commit 73c5711e66a4709b18cb3336010b9f6908e9cdb5, without admin.

Read-back: MERGED at 2026-10-05T01:41:05Z, squash commit f782b334158c5a7e203ac942732fd8bd390e20dd.

Manual-ID finding closed: two-line repair independently verified; merged-tree manual lint and projects guide check passed on main af86064e83928371f935ff490233eaa1ec68c3b8 + exact head. B16 unique among main and all 69 open PRs scanned. Optional independent UI attempt remained blocked at module loading (zero executed tests); not claimed green. No push, CI rerun/cancel, other PR mutation, native protected task approval, release or deployment performed.

Receipts go to TALE-312, TALE-359 and TALE-360. Release owner may include this accepted merge in a later eligible candidate under its existing gates; merge alone does not prove deployment.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Live check of #4317 on main 4f95bd54d, after the merge: the failed-read and recovery paths pass in a real browser. This is evidence, not an acceptance; the PR recorded jsdom only.

Results

  • Failed read: after about 16 s, once the retries are spent, a role="alert" reads "Couldn't load this project's secrets." with Try again.
    • No editor and no Add variable, and the stored name isn't shown.
    • No write: no POST or DELETE to /secrets.
  • Recovery: with the route lifted, Try again pressed from the keyboard brings the stored name back within 254 ms. Focus moves to the named "Environment" group, as the PR describes.
  • After: the API still lists SYNTH_TOKEN_A.

Limits

  • The refresh-failure notice ("Couldn't refresh…") wasn't exercised. Synthetic focus, visibilitychange and online events didn't trigger a refetch, so the draft-keeping path is untested here.
  • Desktop, English, owner role.
  • The probe (s1) and its log are kept in TALE-358's r20261005T0415 evidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(platform): Project Environment turns a generic secrets read failure into an empty editor

1 participant