Repository navigation
fix(platform): word lapsed-session failures and guard the rule - #3763
Merged
Merged
Conversation
The inline env editor and the header Save cluster described a failed save
with the thrown error's message. A backend refusal rethrown as-is carries
its payload on `data` and serializes it into `message` for logs, so the
toast read {"code":"UNAUTHORIZED",...} under its title.
Both now read the message through readableErrorMessage, which returns a
plain error's sentence and nothing for an error carrying `data`, an empty
message or a thrown non-error; the generic "Something went wrong" line
takes its place. The JSON editor's save toast reads it the same way.
Saving or removing a project secret after the session ended toasted the
refusal's serialized payload ({"code":"UNAUTHORIZED",...}) under "Couldn't
save environment", and the write hook's default toast reported the same
failure a second time.
The tab's writes now reject with the refusal's own words through
failureDetail, so a lapsed session reads as its localized sentence and a
fault as the generic line. The secrets hooks leave the failure toast to
the editor. The member preferences page says that saving an Environment
tab that was already open shows the session sentence, in all three
languages, and AUTH-B13 walks it.
failureDetail passed any plain error's message through, so a request that
got no answer showed the browser's own English ("Failed to fetch", "Load
failed" on Safari) under a German or French title, and a runtime fault
showed its developer text ("Cannot read properties of undefined").
A request that got no answer now reads as the localized
common.errors.connectionLost sentence, and an error the JavaScript runtime
raises (TypeError, SyntaxError, RangeError and the rest) yields no detail,
so the surface keeps its own title or fallback. The fetch-failure matcher
moves out of the Sentry filter into one module both read.
The rule that a surface shows a failure's words and never its payload had no guard outside the chat feature. A new guard walks every non-test source under the platform app and the design system and fails on a description or title built from an error's message: the instanceof ternary on one line or several, err.message as a prop or a property, an Error cast and a stringified error. It checks its own shapes against samples, and keeps an allowlist, empty today, whose entries must still match. The last two offenders, the owner sign-up toast and the forced password change's sign-out toast, read the failure through failureDetail. Because the guard reads packages/ui/src as text, the platform's test task now hashes it, and the turbo-inputs guard holds that. The rule is written down beside failureDetail and in the repo contract.
The team dialogs call Better Auth directly and threw its refusal as a plain error, so after the session ended the toast under the localized title read "Unauthorized" for a rename, or the English fallback "Failed to create team" for the bare 401 create-team answers. The developer string "Team ID not returned" reached the toast the same way, and a change of members alone was counted as refused instead of saying the session ended. authClientError reads a Better Auth refusal the way the app reads a backend answer. A 401 UNAUTHORIZED, or a bare 401, is the localized "session ended" sentence and is reported to the recovery flow. Another refusal keeps the library's words, and one without words shows only the title. The dialogs throw it, an answer without a team id counts as a fault, and a membership change refused by an ended session says so.
The version comparison answered every attempt with an English refusal
("Document comparison is offline while the platform AI backend is
rewritten"), showed "Comparison failed" in English for a fault and the
developer's "Invalid comparison response" for a body of the wrong shape.
It reported each failure three times: the action's default toast, the
dialog's toast and the line under the version picker.
The offline refusal now carries a localized sentence. The hook stores a
refusal's own words or the localized "Couldn't compare versions" line,
treats a malformed body as a fault, and leaves the toast to the dialog.
…ssion The Chat health Alert and the Google Drive and Microsoft 365 import toasts read a refusal through failureDetail, but nothing failed if one went back to printing the error's message: their tests fed only plain strings. Each now meets the session door's own refusal in English, German and French, and must show the localized sentence and no serialized payload. The AUTH-B13 automation row lists these tests with the other surfaces'.
After Stay here the standing notice floated over the top of the window. Below about 536 px it spanned the full width and covered the page header, its navigation trigger and actions included, until the person signed in, which defeated staying to copy work. In the dashboard shell the notice now sits in the alert stack above the page, like the other shell alerts, so it covers nothing at any width. On a narrow or short viewport it keeps to its title and Sign in, and it pads the notch itself. A dashboard page without the shell keeps the floating notice. The browser test now renders the real StickyHeader and PanelHeader at a phone's, a short window's and a desktop's size, and the layout test pins where the shell shows it. AUTH-B14 and the member preferences page say where the notice is.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #3685 (a lapsed session shows its sentence, not the payload), from its review. I re-checked each finding on
main(88d74c6) before coding. The branch is rebased on 300bcf0.What changed
Environment tab (high). On
main, saving or removing a project secret after the session ended toastedCouldn't save environmentabove the serialized refusal ({"code":"UNAUTHORIZED",…}). The write hook's default toast also reported the same failure.onSet/onDeletenow reject withfailureDetail(err) ?? common.errors.generic.useSetProjectSecret/useDeleteProjectSecretpasserrorToast: false, so a failed save raises one toast:Couldn't save environmentaboveYour session has ended. Sign in again., localized.@tale/ui,EnvVarListEditor(inline) andEditorActionsread the thrown value through a newreadableErrorMessage(@tale/ui/error-message). It returns a plain error's sentence, and nothing for an error carryingdata, an empty message or a non-error. Where it returns nothing, the toast shows the package's own "Something went wrong. Try again." The JSON editor's save toast reads it the same way.A guard for the rule (medium).
tests/guards/error-message-description.guard.test.tswalks every non-test source underservices/platform/appandpackages/ui/src. It fails on a toast/Alertdescriptionortitlebuilt from an error's message:x instanceof Error ? x.messageternary, on one line or across several;description={err.message}anddescription: err.message;(x as Error).messagecast;String(err).The guard also tests its own patterns against samples. It keeps an allowlist that needs a reason per entry and must stay live; it is empty today. Against
mainit flags the four sites the review named, plusjson-input.tsx's toast title. Two of the flagged sites are Better Auth paths, the owner sign-up step and the forced password change's sign-out; both now read throughfailureDetail, so none needed allowlisting. The rule is written next tofailureDetailand in.agents/repo.md.packages/ui/srcas text,services/platform/turbo.jsonnow hashes$TURBO_ROOT$/packages/ui/src/**fortest. That entry subsumesmain's newglobals.cssinput; both readers stay inOUTSIDE_READS. Theturbo-inputsguard holds it.@tale/platform#test, its i18n suite included.test:uiandtest:browserstill replay;.agents/repo.mdsays so.The seven
failureDetailsurfaces now have lapsed-session tests (medium). Each runs in en/de/fr, and each fails if its surface goes back to.message: Chat health's Alert, the document-history comparison toast (a new dialog test on the real hook and adapter row), the Google Drive and Microsoft 365 import toasts, and team create/edit/delete. The AUTH-B13 automation row lists them.Team dialogs (low).
authClientError(app/lib/auth/auth-client-error.ts) reads a Better Auth{ error }the way the app reads a backend answer:UNAUTHORIZED, or a bare 401, is the localized session sentence and is reported to the recovery flow.create-teamreally answers a bare 401 with an empty body, observed below.Document comparison (low).
history.compareFailed.COMPARISON_OFFLINE, which every comparison meets today) was English in every language. It now carriesdocuments.history.compareOfflinein en/de/fr."Failed to fetch" (the decision asked for).
failureDetailnow reads a request that got no answer as the localizedcommon.errors.connectionLost. That covers Chromium's "Failed to fetch", Safari's "Load failed" and Firefox's wording, using the matcher the Sentry filter already had, now inapp/lib/backend/transport-failure.ts. Any other runtime error (TypeError,SyntaxError,RangeError, …) yields no detail. No app code throws those types for display, and their messages are developer text.Standing notice (low).
Stacking test (low).
session-lapse-recovery.browser.test.tsxnow renders the realStickyHeaderandPanelHeaderat 375×740, 900×400 (short) and 1280×800. It checks every header control and Sign in by hit-test, and checks that the notice stays under an open dialog. It also keeps the floating fallback's over-the-header check.dashboard-layout.test.tsxpins that the shell shows the notice once, above the page.How I verified it
Every new test was run against
main's code (the impl files checked out fromorigin/main, or the surface reverted to.message), and every one failed:The turbo guard fails without the new input.
Real browser (local backend, Vite dev SPA, Chromium 1194; the session signed out through the same cookie jar; toasts recorded as they mount):
mainCouldn't save environment {"code":"UNAUTHORIZED","message":"Your session has ended. Sign in again.",…}Couldn't save environment/Your session has ended. Sign in again.Umgebung konnte nicht gespeichert werden/Deine Sitzung ist beendet. Melde dich erneut an.;Impossible d'enregistrer l'environnement/Ta session a pris fin. Reconnecte-toi.401with an empty bodyTeam konnte nicht erstellt werden/Failed to create teamTeam konnte nicht erstellt werden/Deine Sitzung ist beendet. Melde dich erneut an.401 {"message":"Unauthorized","code":"UNAUTHORIZED"}Couldn't update team/UnauthorizedCouldn't update team/Your session has ended. Sign in again.(fr:Échec de la mise à jour de l'équipe/Ta session a pris fin. Reconnecte-toi.)visual-aspect-analyzer was embedded and signed in, over the notice flow, before and after:
main: the error toast's slide-in jank, page-load CLS 0.013–0.022, the added row's shift, and the phone capsule's flicker during auto-scroll.mainshowed are gone. They came from the tab strip being occluded by the floating notice.Checks run locally, all passing:
tscover the changed platform files, andtscfor@tale/ui.EditorActions/EnvVarListEditor,@tale/ui's env editor, JSON input and editor tests, and the browser tests of both workspaces.lib/i18n/messages.test.ts, the docs suite (35 files),lint:manual,check-guideonauth.md,oxfmt --checkon the repo.oidcOrganizationClaims.The whole platform suite and workspace-wide
tscare left to CI (the sandbox's 4 GB limit).Left open
TOAST_LIMIT1 the person sees the last toast, but two fire. It's a separate sweep.authClientError; this PR moves the team dialogs only.