Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: clear stale external auth validation error after revalidation - #28881

Open
VihaanAgarwal wants to merge 1 commit into
coder:mainfrom
VihaanAgarwal:fix/external-auth-stale-validate-error
Open

fix: clear stale external auth validation error after revalidation#28881
VihaanAgarwal wants to merge 1 commit into
coder:mainfrom
VihaanAgarwal:fix/external-auth-stale-validate-error

Conversation

@VihaanAgarwal

Copy link
Copy Markdown

Fixes #28876

On /settings/external-auth, a row could show a disabled Authenticated button next to Error: token failed to validate, and a "Test Validate" run would toast Application link is valid. while the error text stayed until a hard reload.

The badge and the error come from two react-query entries that were never resynced. The button reads the per-provider query, but validate_error only exists on the list query, and validateExternalAuth only wrote the per-provider cache key. Nothing except unlink ever invalidated the list, so an error captured at page load stuck around after a successful re-auth or validation.

Two changes:

  • validateExternalAuth.onSuccess now also invalidates the list query (exact key), so the refetched link reflects current state.
  • The error text no longer renders on a row that resolves to authenticated, so a transient disagreement between the two endpoints (list validates via refresh with retry, by-ID validates directly) can't show the contradiction either.

Added tests covering both: one drives "Test Validate" from a failed state and asserts the list is refetched and the error clears, one pins that a stale list error never renders next to an Authenticated button. Both fail without the fix. Also set authenticated: false on the Failed storybook story, since a failed-validation link is unauthenticated.

Verification:

Test Files  1 passed (1)
     Tests  2 passed (2)

biome check and tsc -p . clean; the existing device-flow test in pages/ExternalAuthPage still passes.

Written with AI assistance.

@github-actions github-actions Bot added the community Pull Requests and issues created by the community. label Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Pull Requests and issues created by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(site): External Authentication page shows a stale "token failed to validate" error next to an "Authenticated" badge

1 participant