Skip to content

fix(platform): show failed API access reads instead of Access denied - #5088

Closed
tale-code-bot wants to merge 2 commits into
mainfrom
fix/api-settings-access-read-failure
Closed

tale-code-bot wants to merge 2 commits into
mainfrom
fix/api-settings-access-read-failure

Conversation

@tale-code-bot

Copy link
Copy Markdown
Collaborator

Task: TALE-147 on the Development board, from #4767 and its addendum of 2026-10-12.

Problem

A member whose role isn't Owner, Admin or Developer, but who may use the API (through a granted competence, a key they still hold, or a coding-agent connection), saw a false verdict whenever one of their access reads failed. Settings › API said Access denied, or refused a tab they may open, and offered no Try again. The settings rail and the mobile settings list dropped the API entry, so they couldn't reach the page at all. For example, a member who needs to revoke a leaked key was turned away by a read that never answered.

Cause. useApiSettingsAccess decided each tab from data?.x === true, and loading covered only isLoading. Once a read failed, data stayed undefined and every flag read false, so the layout and both menus took a failure for "closed".

Change

  • Hook (use-api-settings-access.ts). It reuses readStateOf, whose unavailable holds still through a retry.
    • A read that never answered leaves the tabs it would open undecided: neither open nor closed.
    • A tab the role or another read already opens doesn't wait on that read, so a developer's grant reads change nothing.
    • A read that answered before keeps its last answer through a failed refresh, as before.
    • New fields: undecided, error, retrying, failureCount and retry (asks only the failed reads again).
    • loading no longer goes back to the skeleton while a failed read is retried.
    • The existing flags keep meaning "proven", so Create API key and Connect a coding agent still appear only when proven.
  • Layout (settings/api/route.tsx), using CatalogLoadError with failureKey, isRetrying and onFocusLost:
    • Every tab closed after all reads answered: Access denied (unchanged).
    • The open tab closed by the role or by a read's answer: its own sentence (unchanged).
    • The open tab undecided: "Your API access didn't load." with Try again, in place of the page. The phone's tab strip stays.
    • The open tab proven while another is undecided: the page, with "Some of your API access didn't load." and Try again above it.
    • The content pane is a named region (API) that takes the focus when the failure leaves.
  • Navigation. listedApiAccess in -nav-items.ts lists the open tabs plus the undecided ones, for the rail, the tab strip and the mobile list (the addendum).
  • Scope note. The hook also reads Connected agents access (feat(platform): add the Connected agents page to Settings #4925, merged after this issue was filed), and accessDenied.apiKeys now names coding agents. So that read gets the same treatment. It is the only change a developer can see, and only while that read fails.
  • Strings. settings.apiAccess.readFailed and partialReadFailed in en, de and fr (de-CH needs no override).
  • Docs. One sentence each in admin/api-keys.md and admin/connected-agents.md, in EN, DE and FR.
  • Manual register. One row in tests/manual/reference/automation.md.

Tested

All commands ran at head 851b478d9, in services/platform unless noted.

New route test (settings/api/route.test.tsx). It runs the real layout, hook, adapter rows, backendFetch and read retry policy against syntheticBackend (500 answers). Only the role and the router are stubbed. Cases:

  • A Member with a key grant, with the key rule, model grant and connections reads failing in turn. Each shows the failure with Try again, never accessDenied.apiKeys, apiTab, apiModels or apiAgents. After the read heals and Try again is pressed, the REST tab shows.
  • Both grant reads failing.
  • Models and Connected agents while their own read fails.
  • A tab the role closes is still refused.
  • Models is refused once its read answers no.
  • A developer whose grant reads fail sees no change.
  • Try again keeps its node and focus through a retry that fails again, then hands the focus to the section.
  • axe on the failure state.
  • Controls: a healthy key grant shows REST; a member whose reads open no tab still sees Access denied.

Results:

  • Regression fails before the fix. With the source files reverted to main and the new tests kept, 12 of the new cases fail. The old layout renders accessDenied.apiKeys and apiModels for failed reads, which is the reported bug.
  • bunx vitest --run --config vitest.ui.config.ts on the touched and neighbouring files (route, loader, hook, rail, mobile list, MCP sections, agents section): 11 files, 99 tests pass. The route test passed 13/13 on five repeated runs.
  • bunx oxlint --type-aware on the changed files: clean.
  • bunx tsc --noEmit (whole platform program): exit 0.
  • bunx vitest --run --project server lib/i18n/ tests/guards/domain-specs.guard.test.ts tests/guards/error-message-description.guard.test.ts tests/guards/single-failure-toast.guard.test.ts: 14 files, 714 tests pass. messages.test.ts with --silent=false printed no advisory findings.
  • services/docs: bunx vitest --run: 38 files, 716 tests pass.
  • Repository root: bun run lint:manual, bun run lint:conflicts and bun run lint:links pass. oxfmt ran through the pre-commit hook.

Not tested

  • The full test, test:ui and test:browser suites, knip, SAST and E2E were not run locally. The pre-commit SAST step skips when uncached. This PR's CI and the merge queue run them.
  • No live stack in this worker, so I didn't watch the change in a running app or run the visual analyzer.
  • The de and fr wording was written natively but not reviewed by a second speaker.

Closes #4767

A member whose API access read failed was told Settings › API was not
theirs. useApiSettingsAccess took a read that never answered for "no
access", so the layout showed Access denied, or a tab's refusal, with
nothing to try again, and the settings rail and the mobile settings
list dropped the API entry.

The hook now leaves the tabs such a read would open undecided (through
readStateOf, which holds still across a retry) and exposes error,
retrying, failureCount and retry. A tab the role or another read
already opens does not wait on it, so a developer's grant reads change
nothing; the Connected agents read counts the same way. The layout
names the failure with Try again in place of an undecided tab, and
above an open tab while another stays undecided. The rail, the tab
strip and the mobile list keep the undecided tabs listed.
The API keys and Connected agents guides now say what a member sees
when Tale cannot check their access: the page says so and offers Try
again rather than turning them away, and the pages it could confirm
stay open. EN, DE and FR.

@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.

Review of head 851b478d961379990e9e0f2b0d304843f8cafaf7 (base main 9be5cadacb5f59cd6b2cc67c7840e3c0101bdde2), TALE-147. Approve.

Diff (read whole, 19 files):

  • useApiSettingsAccess: a read that never answered (readStateOf(...).unavailable) leaves the tabs only it could open undecided, never closed. A tab the role or another read proves does not wait on it, so a developer's grant reads decide nothing. retry asks only the failed reads, and loading no longer returns to the skeleton during a retry.
  • Layout: an undecided open tab shows CatalogLoadError ("Your API access didn't load.") with Try again in place of the page. A proven tab with another undecided gets the partial notice above the page. Refusals by role or by an answered read are unchanged.
  • Navigation: the rail and the mobile settings list keep undecided tabs (listedApiAccess), which covers the 2026-10-12 addendum on #4767.
  • Connected agents: its access read gets the same treatment. It is the same concept in the same hook, and the section's refusal text already names coding agents.
  • Sweep: strings in en, de and fr (de-CH needs no override); docs sentences in EN, DE and FR admin/api-keys.md and admin/connected-agents.md; a row in the manual automation register. Branch, commits and the PR title follow the contract, and the body says Closes #4767.

Run myself (credentials removed, deps from the lockfile under host lease a68bde4f):

  • Head, 5 UI files (vitest.ui.config.ts: the new settings/api/route.test.tsx, the hook test, the rail and menu-group tests, model-endpoints-section.test.tsx): 67/67 passed. The route test alone: 13/13.
  • Regression: main's 5 source files (hook, -nav-items.ts, route.tsx, settings-rail.tsx, use-settings-menu-groups.ts) under the head's route test give 10 failed, 3 passed. The failures render "Access denied" / "Using API keys or connecting a coding agent takes the Owner, Admin or Developer role…" and never "Your API access didn't load."; the 3 controls (healthy grant, refused member, developer) pass. Tree restored.
  • i18n parity plus guards (lib/i18n/, error-message-description, single-failure-toast, domain-specs): 14 files, 714/714 passed. lint:manual ok.

Required checks on this head: all 7 CI ready passed: Checks 40920212329, Commitlint 40920212488, SAST 40920212159, E2E 40920212201, CLI 40920212164, Security 40920212309, Build 40920212347.

Not run by me: the full UI shards, Browser and E2E (merge queue only), and a live stack (none here).

@tale-review-bot
tale-review-bot added this pull request to the merge queue Oct 29, 2026
@yannickmonney
yannickmonney removed this pull request from the merge queue due to a manual request Oct 29, 2026
@yannickmonney yannickmonney reopened this Oct 29, 2026
@tale-review-bot
tale-review-bot enabled auto-merge (squash) October 29, 2026 20:19
@tale-review-bot

Copy link
Copy Markdown
Collaborator

Reviewer: not landing yet. The approved head 851b478d961379990e9e0f2b0d304843f8cafaf7 has no CI round under the current workflows.

  • The newest Checks run on this head, 40947301085 (created 20:14 UTC), checked out Merge 851b478d961379990e9e0f2b0d304843f8cafaf7 into 9be5cadacb5f59cd6b2cc67c7840e3c0101bdde2 (merge commit 160317d). That is main from before 0da08205 ("ci: land each pull request on its own, without the merge queue"), so the run uses the old workflows.
  • In that run, UI (both jobs), Browser, Performance and Backend integration were skipped. The current .github/CI.md has a pull request run every suite its paths owe. Its CI ready (Checks) job is still queued.
  • What lands it: a fresh round on the same head under the current workflows. Closing and reopening the pull request rebuilds its test merge on the current main; draft→ready does not. My approval of 851b478d961379990e9e0f2b0d304843f8cafaf7 stands while the head is unchanged. Once every CI ready (...) of that round has finished green, it lands with gh pr merge --squash --auto --match-head-commit 851b478d961379990e9e0f2b0d304843f8cafaf7 after a hold read.

@yannickmonney

yannickmonney commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Reopened so the checks run again. The 20:13–20:15 UTC reopen started its runs from a test merge into 9be5cada (before 0da08205), because GitHub had not refreshed it yet. This reopen's runs start from the test merge 3612405e11, into 0da08205. The head is unchanged (no new commit).

@yannickmonney

Copy link
Copy Markdown
Contributor

Landed on train as 7564786: squashed at the approved head after the fast gate (formatting, typecheck, build). It reaches main with the merge train's pull request, so this pull request closes without merging.

yannickmonney pushed a commit that referenced this pull request Oct 30, 2026
Reviewed and approved in pull request #5088 at 851b478.

Closes #4767
Task: TALE-147
@yannickmonney
yannickmonney deleted the fix/api-settings-access-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): Settings › API shows Access denied to a member with an API grant when their access read fails

3 participants