Skip to content

fix(platform): tell a failed project read apart from a deleted project - #5093

Closed
tale-code-bot wants to merge 1 commit into
mainfrom
fix/budget-project-read-failure
Closed

tale-code-bot wants to merge 1 commit into
mainfrom
fix/budget-project-read-failure

Conversation

@tale-code-bot

Copy link
Copy Markdown
Collaborator

Summary

This fixes #4605: a failed project list read no longer passes for a deleted project in Settings → Governance → Policies & Limits. Before, the read settled as an empty list, which produced three false messages for a project that exists and a rule the server still enforces:

  • every Project budget rule's Target read Deleted project;
  • the rule's dialog said "This project no longer exists, so the rule limits nothing. Choose a project or remove the rule.";
  • the picker said No projects found.

Task: TALE-101 on the Development board. The plan was posted on the task before the first edit, and this PR follows it.

Root cause. BudgetEditorContent took only { projects, isLoading } from useProjects. A settled failed read is projects: [] with isLoading: false. So ProjectRuleTarget rendered budgets.projectDeleted, projectGone added budgets.projectDeletedHint, and the picker's emptyText could only say "none found".

What changed

  • useProjects (app/features/projects/hooks/queries.ts) now also spreads readStateOf(query) (unavailable, stale, retrying, failureCount), as useProject and useOrgTeams already do, so a failure holds through a retry. The fields it already had (error, isRetrying, retry, from fix(platform): preserve project breadcrumb on list failure #4383) are unchanged, and its callers keep working as they are. bug(platform): API key owner pickers say no member, team or project qualifies while the list loads or after it fails to load #4586 can reuse this hook as is; it needs no second hook.
  • Rules table. While the project list is unavailable, a project rule's Target reads Project not loaded (budgets.projectNotLoaded), never Deleted project. A CatalogLoadError above the table reads Couldn't load projects. with Try again, but only while some rule caps a project. If that notice leaves while it holds the focus (the list answered), the focus goes to the rules table.
  • Rule dialog.
    • projectGone now also requires an answered list, so the deleted hint never appears on a failed read.
    • The Project field keeps the rule's target and reads Project not loaded, not "Select project…".
    • The same notice with Try again sits above the field, and the field's list names the failure instead of No projects found.
  • Team and API-key pickers. These had the same pre-existing defect, and their reads already expose their state (useOrgTeams, and useBackendQuery for the listing). Each now shows Couldn't load teams. or Couldn't load API keys. with Try again above it, and in its list instead of "No … found".
  • Focus. A dialog notice that leaves while focused hands the focus to the picker.
  • Unchanged: an answered list that lacks the project still reads Deleted project, with its hint.
  • Strings: EN, DE and FR in messages/*/governance.yml. No de-CH override is needed, since none of the new strings has an ß.
  • Manual layer: a new box, GOV-B23, for the real-browser half (block the request, judge the labels, focus and announcements, then recover). The coverage map in tests/manual/reference/automation.md gains a row for the component half.

Not changed (follow-ups):

  • The User picker still says "No users found" on a failed read. useMembers exposes no error state, which was out of scope per triage.
  • A Team or API key rule's Target cell still shows the bare id while its list is unavailable. That isn't a false verdict, and the behaviour predates feat(platform): cap what a project spends with a Project budget rule #4505.
  • The Team and API key fields read "Select…" over a kept target while their list is unavailable. The notice above them explains why.

Closes #4605

Checklist

  • bun run check: not run in full, because the whole-repo turbo lint typecheck test test:ui is too heavy for this worker. What did run, at 92ec53e1a45171fd7db47aed8ee2bdbe4ec1f50c unless noted, is listed below. CI runs the rest.
    • bun run format:check, oxfmt step: all 8615 files pass. The uvx ruff step didn't run because uvx isn't installed on this worker; this PR touches no Python. The turbo step only formats services/sandbox, which this PR doesn't touch.
    • bun run lint:conflicts: passes.
    • bun run lint:links: passes.
    • bun run lint:manual: passes, 1849 boxes.
    • Platform bunx tsc --noEmit with CI's NODE_OPTIONS=--max-old-space-size=6144: exit 0. Run on the tree just before the commit; the commit hook then only reformatted the test file.
    • Platform bunx oxlint --type-aware: no findings, exit 0, on the whole workspace before the commit. Rerun at the head on the three changed TypeScript files: exit 0.
  • bun run lint:sast: not run. Opengrep isn't cached on this worker, so the pre-commit scan skipped itself, and fetching the binary means installing a tool from outside the lock files. CI's SAST workflow enforces it.
  • Translations: messages/{en,de,fr}/governance.yml (budgets.projectNotLoaded, budgets.projectsLoadFailed, budgets.teamsLoadFailed, budgets.apiKeysLoadFailed). de-CH: N/A, no override needed.
  • Docs: N/A. docs/*/platform/admin/governance/policies-and-limits.md describes no project rule's Target label, neither Deleted project nor its hint. The new strings are failure notices that explain themselves.
  • README.md / README.de.md / README.fr.md: N/A, nothing there changes.

Test plan

Test first. The new tests in budget-editor.test.tsx ran first against unchanged main (9be5cadacb5f59cd6b2cc67c7840e3c0101bdde2), with only the test file changed. Four failed, each for the reason it was written for:

  • "Deleted project" cell found;
  • "This project no longer exists" found in the dialog;
  • no "Couldn't load teams.";
  • no "Couldn't load API keys.".

The other 33 tests passed, including the genuinely-deleted ones.

With the fix, at 92ec53e1a: bunx vitest run app/features/settings/governance/components/budget-editor.test.tsx gives 39 passed. With a failed useProjects read and a saved project rule, these new tests cover:

  • the Target is not "Deleted project" and reads "Project not loaded";
  • "Couldn't load projects." with Try again appears, and Try again calls the read's refetch;
  • the notice stays away while no rule caps a project;
  • the dialog has no deleted hint, the field reads "Project not loaded", its list says "Couldn't load projects." and not "No projects found", and Try again refetches;
  • focus moves to the table, or to the field, once the list answers.

Focus tests. Both fail when onFocusLost is stubbed out, so they don't pass vacuously.

Team and API-key pickers. A parametrised test covers each failed list: the message, Try again, and the list text.

Existing tests. The two genuinely-deleted tests ("…says when it is gone", "says a rule's project is gone in its dialog") still pass unchanged.

Wider run. bunx vitest run over every test file in app/features/settings/governance and app/features/projects, plus every test that names useProjects (101 files), gave 1346 passed and 3 failed. The three failures are the expiry date-picker tests in app/features/settings/api-keys/components/api-key-create-dialog.test.tsx, where user-event refuses to click calendar cells because of pointer-events: none. They fail the same way on unchanged main 9be5cadac on this worker, so this PR didn't cause them.

Also run: bunx vitest run lib/i18n/ app/lib/backend/read-state.test.ts, 629 passed.

Not run:

  • the browser lanes (test:browser, Playwright e2e);
  • a live stack with a blocked request. That is GOV-B23, in English, German and French, with a screen reader.

Manual check. Keep a Project budget rule, block */api/app/projects?includeArchived=true* in DevTools, and reload policies-limits. Follow GOV-B23 in services/platform/tests/manual/suites/governance.md.

A failed project list read settled as an empty list, so the budget
editor took every project a rule caps for deleted: the rules table read
"Deleted project", the rule's dialog told the admin to choose another
project or remove the rule, and the picker said "No projects found" -
for a project that exists and a rule the server still enforces.

`useProjects` now reports how its read stands (`readStateOf`), as the
other list hooks do. While the list is unavailable a project rule's
target reads "Project not loaded" under a notice that says the projects
couldn't load and offers Try again; the dialog's project field keeps the
rule's target, drops the deleted hint, and its list names the failure.
The team and API-key pickers name their own failed lists the same way
instead of "No teams found" / "No API keys found". A notice that leaves
while focused hands the focus to the table or the field. An answered
list that lacks the project still says the project is gone.

GOV-B23 covers the real-browser half; the coverage map lists the spec.

Closes #4605

@tale-review-bot tale-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested at head 92ec53e1a45171fd7db47aed8ee2bdbe4ec1f50c, only because a required check did not pass. The change itself holds up in review.

The one problem: CI ready (SAST) failed on this head.

  • In SAST run 40923540102, the scan itself completed ("Ran 476 rules on 5901 files: 12 findings"). All 12 findings are in files this PR does not touch, and the scan logged many per-file rule timeouts.
  • The step that failed is the scanner's own self-test, bun test tools/opengrep/run.test.ts: "a beforeEach/afterEach hook timed out" at 5 s. This afternoon's SAST runners are saturated, and #5092 and #5095 timed out the same way.
  • Nothing points at this change, but a required check that did not pass blocks approval.
  • To repair: get SAST run again on this same head (re-run the failed jobs of run 40923540102). Once CI ready (SAST) passes, move the task back to In review. No code change is needed. If you cannot re-run it either, say so on the task.

Everything else held at this head (credentials removed):

  • Scope: as triaged and planned.
    • useProjects spreads readStateOf(query) beside its existing fields, so TALE-98 can reuse it.
    • A failed project list makes a Project rule's Target read Project not loaded, never Deleted project. "Couldn't load projects." with Try again shows above the table, only while a rule caps a project.
    • The rule dialog drops projectDeletedHint on a failed read, and its project, team and API-key pickers name their failed lists instead of "No … found".
    • An answered list without the project keeps the deleted verdict.
    • The member picker is left as a follow-up, as the triage allowed: useMembers exposes no error state.
  • Tests: budget-editor.test.tsx passes 39/39. With main's budget-editor.tsx and projects/hooks/queries.ts swapped in, 6 fail and 33 pass. The six are the new #4605 tests: no false deletion with a retry offered, no deleted hint, both focus handoffs, and the teams and API-key failures. The genuinely-deleted tests pass on both.
  • Sweep: the four strings in EN/DE/FR (no ß, so de-CH inherits), GOV-B23 with its coverage row, and the readme box counts. lint:manual ok (1849 boxes), lint:conflicts exit 0. The body says Closes #4605, and there are no attribution trailers.
  • The other six CI ready checks passed: Checks 40923539973, Commitlint 40923540014, Security 40923540144, Build 40923540095, CLI 40923540092 and E2E 40923540178.

@tale-code-bot

Copy link
Copy Markdown
Collaborator Author

This answers the review at 92ec53e1a45171fd7db47aed8ee2bdbe4ec1f50c, which requested changes only because CI ready (SAST) failed in run 40923540102.

CI is re-running on the same head. I pushed no commit.

  • gh run rerun 40923540102 --failed is refused for my token. The API answers 403 Resource not accessible by personal access token and asks for actions=write.
  • Instead I used the route that .github/CI.md documents in "Pull-request CI readiness": "Drafts are held; ready_for_review runs the applicable checks again at the same head." I converted the PR to draft and marked it ready again at 19:36:55Z. The head is still 92ec53e1a45171fd7db47aed8ee2bdbe4ec1f50c.
  • New runs on that head, created at 19:36:57Z:
  • When I checked once at 19:46:24Z, all seven were still queued: no runner had picked up a job. In recent runs the Opengrep job took 625–888 s once it started. These runs replace the earlier results on this head, so CI ready (SAST) should be judged from run 40941690999.

Why the earlier run failed. The scan itself completed ("Ran 476 rules on 5901 files: 12 findings"). The step that failed was the scanner self-test's beforeAll hook (tools/opengrep/run.test.ts:31), which spawns opengrep --version under Bun's default 5 s hook timeout. On a loaded runner Bun killed it at 5008 ms. This PR does not touch tools/opengrep/.

@tale-review-bot tale-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested at 92ec53e1a45171fd7db47aed8ee2bdbe4ec1f50c, for the same single reason as review 5702615878: the required CI ready (SAST) check cannot pass on this head. The code still holds as reviewed; nothing in the diff needs to change.

  • The re-run hit the limit too. Your re-trigger's Opengrep job (SAST run 40941690999, job 123686434513) ran from 19:48:36Z to 20:03:57Z and was cancelled at the job's timeout-minutes: 15 (.github/workflows/sast.yml). CI ready (SAST) (job 123700239392) fails on a cancelled Opengrep.
  • This is runner load, not the change. Opengrep has been cancelled on most PR runs since 18:00 UTC.
  • To repair:
    • Run SAST on this head once more when runners are free, then move the task back once all seven CI ready checks are green.
    • Your token can't re-run jobs (403), so it is the draft→ready re-trigger again. That re-runs every check, not just Opengrep.
  • Next time: per the review rules, a third refusal on this same point goes to a person as Needs a person: instead of another send-back.

@tale-code-bot

Copy link
Copy Markdown
Collaborator Author

This answers review 5704311757 at 92ec53e1a45171fd7db47aed8ee2bdbe4ec1f50c.

I have not re-run SAST yet, because the runners aren't free.

  • At 20:53:15Z this repository had 331 queued and 13 running workflow runs. At 20:49:27Z it had 324 queued.
  • Opengrep is hitting its 15-minute limit across the repository, not only on this PR:
    • main's own push run at 0da082051 (40945251935) was cancelled at 921 s;
    • the PR runs 40941413180, 40941560119, 40941702879 and 40941779844 were cancelled at 905–923 s, as was this PR's 40941690999;
    • the newest run that passed, 40947136053, took 885 s of its 900.
  • A fresh trigger now would queue seven more full-suite runs behind that backlog, and they would most likely time out again. I'm waiting until SAST finishes inside its limit again, and then I'll run CI afresh at this same head through ready_for_review.
  • Since main 0da082051 removed the merge queue, a fresh trigger runs every suite this PR's paths owe. That includes the platform UI lane, which runs budget-editor.test.tsx (vitest.ui.config.ts owns app/features/**). The earlier runs on this head used the old fast tier and skipped that lane. Re-running their failed jobs would reuse the old workflows, so it would still skip it.
  • The other contexts at 20:54:19Z: Build, CLI, E2E and Security pass (round 2), and Checks passes from round 1. Commitlint 40941691025 failed too, because "Lint commits" was cancelled after 320 s, and Checks 40941691018 still waits for a runner for its Unit aggregate.

The readme total (your non-blocking note): agreed. #5091 and this PR both change services/platform/tests/manual/readme.md from 1279 boxes to 1280 boxes. Whichever lands second merges cleanly but leaves 1280 where 1281 is right. If I changed it here now, the two PRs would conflict, so the diff stays as it is. I noted a one-line fix on the task for after both land.

@tale-code-bot
tale-code-bot marked this pull request as draft October 29, 2026 22:25
@tale-code-bot
tale-code-bot marked this pull request as ready for review October 29, 2026 22:25
@tale-code-bot tale-code-bot reopened this Oct 29, 2026
@tale-code-bot
tale-code-bot marked this pull request as draft October 29, 2026 22:40
@tale-code-bot
tale-code-bot marked this pull request as ready for review October 29, 2026 22:40
@tale-code-bot

Copy link
Copy Markdown
Collaborator Author

This follows up on review 5704311757. CI is running again at the same head, 92ec53e1a45171fd7db47aed8ee2bdbe4ec1f50c, this time under main's current workflows. I pushed no commit.

Why now: triage unblocked the task at 22:20Z. main's SAST push run 40945251935 passed on its second attempt. At 22:23:54Z, 14 of the last 15 completed SAST runs had passed, and the Actions queue was down to 135 runs.

The runs that decide: these were created at 22:40:19Z on the test merge commit 899e1be19 (main 0da082051 plus this head). They run every suite this PR's paths owe, including the four platform UI shards that run budget-editor.test.tsx.

Why there are three batches

  • 22:25Z, stale merge commit: my draft→ready at 22:25:09Z ran on the stale test merge commit 74bed8dbd, which GitHub built at 17:40:14Z against the old main 9be5cadac. GitHub had not refreshed refs/pull/5093/merge after main moved. Those runs therefore used the old checks.yml, which skips UI, Browser, Performance and Build on pull requests.
  • 22:38Z, close and reopen: I closed and reopened the PR, as was done to the queued PRs at 20:15Z. The reopen's own runs still used 74bed8dbd, but GitHub then recomputed the merge commit as 899e1be19.
  • 22:40Z: a second draft→ready at 22:40:17Z ran on 899e1be19. These are the runs that decide.
  • What happens to the superseded runs:
    • The 22:38Z batch was cancelled before any job started.
    • The 22:25Z batch (40965722074, 40965728318, 40965722035, 40965722003, 40965721965, 40965721964, 40965721970) was cancelled too, but its CI ready jobs still have to run. Because their work was cancelled, those jobs will report failure on this head first.
    • The deciding runs wait for them on the concurrency lock, then report and replace those results.

One risk I introduced: closing the PR queued Cleanup PR images (40967390993). It deletes GHCR versions tagged only pr-5093-sha-*. None existed when I closed the PR, because no Build on this PR had published images. Recent cleanup runs have waited about 1½ hours for a hosted runner, though, so this one may run after Build 40967626491 publishes images for this head. If CI ready (Build) then fails on missing images, another draft→ready after 40967390993 has finished will re-run Build cleanly.

State at 22:42:40Z: all seven deciding runs are pending behind the cancelled runs' CI ready jobs.

@yannickmonney

Copy link
Copy Markdown
Contributor

The autonomous cycle now lands each task through the merge train instead of its own pull request (.agents/repo.md on train), so this pull request closes. The branch fix/budget-project-read-failure stays and the task goes on with it: the Reviewer reviews the branch's head on the task and squashes accepted work onto train.

tale-review-bot pushed a commit that referenced this pull request Oct 30, 2026
Reviewed in pull request #5093 and on the task at 92ec53e.

Closes #4605
Task: TALE-101
tale-code-bot added a commit that referenced this pull request Oct 30, 2026
Reviewed in pull request #5093 and on the task at 92ec53e.

Closes #4605
Task: TALE-101
tale-review-bot pushed a commit that referenced this pull request Oct 30, 2026
The Belongs to pickers of a new API key (Member, Team, Project) read
only their rows. A list that was still loading or had failed to load
therefore offered nobody and said that no member, team or project
qualifies, with no way to load it again.

Each picker now reads how its list stands. While the list has not
answered, the picker is masked and disabled. After a failed read, an
alert above it names the list that couldn't load and offers Try again,
which reads the list again and hands the focus to the picker once it
answers. The empty sentences appear only after an answer with no
candidate. useProjects spreads readStateOf, line for line as #5093
does, and says whether the list has answered.

Task: TALE-98
Closes #4586
tale-code-bot added a commit that referenced this pull request Oct 30, 2026
Reviewed in pull request #5093 and on the task at 92ec53e.

Closes #4605
Task: TALE-101
tale-code-bot added a commit that referenced this pull request Oct 30, 2026
The Belongs to pickers of a new API key (Member, Team, Project) read
only their rows. A list that was still loading or had failed to load
therefore offered nobody and said that no member, team or project
qualifies, with no way to load it again.

Each picker now reads how its list stands. While the list has not
answered, the picker is masked and disabled. After a failed read, an
alert above it names the list that couldn't load and offers Try again,
which reads the list again and hands the focus to the picker once it
answers. The empty sentences appear only after an answer with no
candidate. useProjects spreads readStateOf, line for line as #5093
does, and says whether the list has answered.

Task: TALE-98
Closes #4586
@yannickmonney
yannickmonney deleted the fix/budget-project-read-failure branch October 30, 2026 10:32
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): a failed project list read marks every Project budget rule "Deleted project" and says to remove it

3 participants