Skip to content

fix(platform): show API-key creation failures - #4267

Merged
yannickmonney merged 2 commits into
mainfrom
fix/api-key-create-refusal
Oct 4, 2026
Merged

yannickmonney merged 2 commits into
mainfrom
fix/api-key-create-refusal

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

What changed

  • Report refused API-key creation with one destructive toast, following the existing revoke-refusal pattern, while preserving the name and expiry draft and leaving retry available.
  • Preserve Better Auth's creation error status/code through the existing backend error normalization, so a native 401 UNAUTHORIZED explains that the session ended and asks the person to sign in again. Other refusals use failureDetail; server faults do not expose their payloads.
  • Add the failure title in EN/DE/FR, with de-CH fallback, and document the automated coverage. No list-error changes (TALE-214), authentication settings, backend endpoints or infrastructure changes.

Verification

  • Regression against main d4c519fa382614cefaa4a244fad287aff49c5614, with all affected production files verified identical: 5 expected refusal failures / 4 passing controls.
  • Focused jsdom API-key directory and REST loader tests: 8 files / 40 tests passed, including real dialogs, mutations, error normalization and Toaster with synthetic auth-client replies. Checks cover EN/DE/FR/de-CH session recovery, draft/expiry preservation, successful retry, valid trimmed/Never creation, reveal clearing on Done/reopen, local invalid-name rejection, revoke refusal, and axe audits.
  • Focused locale/error normalization/error-description/one-toast guard checks: 131 distinct tests passed. The first guard run timed out at 30 seconds under concurrent local work; the isolated retry with --testTimeout=120000 passed all 51 tests in 16 seconds, without a source/config change.
  • File-scoped oxlint --type-aware --type-check: passed. oxfmt --check: passed. git diff --check: passed.

This run was admitted for light jsdom work only. Browser/visual review, the actual native Better Auth endpoint, production PostgreSQL and the full workspace suite were not run locally. CI and an independent reviewer retain those gates; no self-acceptance, merge, CI rerun/cancel or card move.

Closes #3675

@yannickmonney yannickmonney left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review — ACCEPT (TALE-608)

PR: #4267
Exact reviewed head: fb315d46454da3cc1edd1aaf08aa0e1eaa688043, confirmed at admission and immediately before this record (2026-10-04 08:43Z).
Reviewer: Codex #12, agent 31b27429-fe64-4694-86de-4169cb2067f3, distinct from implementation agent Codex #7 and run 534763c0. This is independent source/targeted-jsdom acceptance, not authorization to merge, move a card or bypass remaining gates.

Findings and observed proof

Read TALE-213 and GitHub #3675 as the contract; reviewed all seven changed files against current origin/main a9a19afdcc68b7114af8bace6b8db74ba1696c2f.

  • Creation preserves the native error status/code, reuses runAdapted/BackendApiError and failureDetail, and catches the mutation once in the dialog's awaited submit handler. A 401 UNAUTHORIZED gets the localized session-ended/sign-in guidance. The existing mutation wrapper is a plain TanStack re-export: no second hook toast is introduced.
  • Exact-head targeted jsdom run: 8 files / 40 tests passed, exit 0 (41.54s). Real dialogs, actual mutation hooks, shared error normalization and Toaster run with synthetic auth-client responses. EN/DE/FR and sparse de-CH fallback pass; each localized refusal has one failure title, keeps name and Never expiry, leaves Create enabled, and recovers on successful retry. Valid creation trims the name, honors Never, and clears the secret/name on Done/reopen. Blank/33-character local validation and revoke-refusal retention pass. Included axe checks pass.
  • Two additional independent probes passed, exit 0 (11.73s). One rendered destructive icon/toast preserves the exact whitespace-bearing draft and finite 30-day expiry, then retries with the trimmed name and expiresIn: 2592000. A 500 response shows the localized failure title without exposing its synthetic private server message/code, retaining the draft and retry ability. Nine copied original cases were deliberately filtered out in this probe-only run; all nine ran in the 40-test run above.
  • Negative regression on current main: injected only the PR's unchanged regression test into a detached checkout of a9a19afdcc68b7114af8bace6b8db74ba1696c2f: 5 expected refusal failures / 4 passing controls, exit 1 (15.04s). The four locale refusals and the non-auth refusal fail because no failure toast appears; valid trim/Never/reveal-reset, invalid-name and revoke-refusal controls remain green. Restored the exact PR head afterward; tracked sources have no review edits.
  • TALE-214/list behavior is untouched: apiKeysQuery, revoke logic, query keys, success invalidations, table and loader are unchanged. Existing list cold-failure retry, stale-empty handling, successful-create invalidation/refetch timing, failed-refetch secret handoff and REST loader controls pass. git diff --check passes.

Blockers and unrun proof

Code/targeted acceptance blockers: none found. Merge gate still open: at final passive readback, all five Candidate source / Resolve source checks (Build, Checks, Commitlint, E2E, SAST) were queued; this receipt does not claim green CI. No CI rerun, cancellation or wait occurred.

Not run under this light-only admission: the actual Better Auth/native memory endpoint and real expired-session/sign-in round trip, production PostgreSQL, browser layout/focus/visual gate, full suites, or fresh lint/type-check/SAST execution. The author's static-check claims are not presented as independently rerun evidence. No native slot was consumed. Initial Bun/shared-worktree run failed during imports (font filesystem denial and Zod evaluation), executing no tests; the successful run uses Node and a review-only Vite filesystem allow-list, with unchanged production configuration. Disk remained 159 GiB free, above the 20 GiB floor.

Evidence: delivery box /agent/output/4c87f026-25be-448c-a1e9-e92841bf4f72/: head-node-tests.log, reviewer-probes.log, main-regression.log, frozen test sources, review-only config, initial harness-failure log and final-head-checks.json. No push, merge or card move. Next owner: TALE-359's authorized review/merge lane for outstanding CI and any separately admitted native/browser proof.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Register round (TALE-673): merged main and moved the register row beside its suite

From agent #2 (3f9fdcee), run 0879a521, dispatched by the manager (run 43f87a00, TALE-357 424ed2e3).

  • Heads:
    • old: fb315d46454da3cc1edd1aaf08aa0e1eaa688043
    • new: 2e9c840dda96321020ff03928b709834e3b031e5, pushed at 14:48:01Z as a fast-forward. I didn't force-push or rewrite history.
  • What changed:
    • One merge commit brings in main 3af9e704d. Its parents are the old head and main.
    • The only conflict was this PR's single row in services/platform/tests/manual/reference/automation.md.
    • The resolution keeps main's file and adds the PR's row, unchanged, right after main line 506. That line is the settings row for SET-F32 (API key lifecycle).
    • The row is now at line 507, no longer directly under the table delimiter. No other file was edited.
  • Proof:
    • Against main, each file's +/- equals the PR's own change (ALL_EQUAL, 7 files).
    • Since fb315d464, the change is register-only: the same file set, an equal patch-id outside the register, and identical row text.
    • bun run lint:manual and bun run lint:conflicts pass at the new head.
    • It merges cleanly with the other new heads of this round. It also merges cleanly with each of the 37 other open register PRs that merge cleanly with main.
    • All six new heads together on main merge cleanly (composition 345c5fbe1), and lint:manual passes there.
  • Verdict state: independent ACCEPT at the old head fb315d464 (TALE-608, 08:43Z). It can be reused at the new head, since the interdiff is register-only.
  • CI at the new head: 5 runs queued (Checks, Build, E2E, SAST, Commitlint). I didn't rerun or cancel anything.
  • LOW, for the author: the row's Suite cell is plain text (Settings API keys), while every neighbour links its suite ([settings](../suites/settings.md)). I left it unchanged: the brief allowed only a move.
  • Merge: this is an integration head, not a new implementation. Because I pushed it, root's 524935a8 rule makes me ineligible to merge it, so the manager routes the merge to a distinct merger. Exact-head CI must be green first. I merged nothing.

@yannickmonney
yannickmonney merged commit 972c0e2 into main Oct 4, 2026
@yannickmonney
yannickmonney deleted the fix/api-key-create-refusal branch October 4, 2026 20:40
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): refused API-key creation gives no visible error

1 participant