Skip to content

feat: keep original token refresh error in external auth#19339

Merged
Emyrk merged 5 commits into
mainfrom
stevenmasley/refresh_error_raise
Aug 14, 2025
Merged

feat: keep original token refresh error in external auth#19339
Emyrk merged 5 commits into
mainfrom
stevenmasley/refresh_error_raise

Conversation

@Emyrk
Copy link
Copy Markdown
Member

@Emyrk Emyrk commented Aug 13, 2025

External auth refresh errors lose the original error thrown on the first refresh. This PR saves that error to the database to be raised on subsequent refresh attempts

Addresses: #18811

The issue assumed refresh tokens were being tossed for temporary issues (like an IdP being down). We have code to handle this, however the original error being lost made that code invisible. By keeping the original error, now the reason for the token being invalid is saved (assuming it is a refresh error).

Error now

Screenshot From 2025-08-13 10-48-20 Screenshot From 2025-08-13 10-48-05

Before

This is the behavior before. The first time this failure occurs, it is raised. Subsequent errors always show Error: token expired, refreshing is either disabled or refreshing failed and will not be retried. This subsequent error makes it difficult to debug the original cause.

Screencast.From.2025-08-13.10-29-11.webm

Future work

The error could be better formatted. This PR does not attempt to update the error format, it just retains the first error message.

@Emyrk Emyrk marked this pull request as ready for review August 13, 2025 16:59
Copy link
Copy Markdown
Member

@aslilac aslilac left a comment

Choose a reason for hiding this comment

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

mostly makes sense to me, though I'm not very familiar with external auth stuff. might be worth waiting to see if someone else comes along to review.

Comment thread coderd/database/queries/externalauth.sql
Comment thread coderd/externalauth/externalauth.go Outdated
Emyrk added 5 commits August 14, 2025 09:22
External auth refresh errors lose the original error thrown on the
first refresh. This PR saves that error to the database to be raised
on subsequent refresh attempts
@Emyrk Emyrk force-pushed the stevenmasley/refresh_error_raise branch from cccd7ae to b0a1694 Compare August 14, 2025 14:23
@Emyrk Emyrk merged commit 4926410 into main Aug 14, 2025
44 of 47 checks passed
@Emyrk Emyrk deleted the stevenmasley/refresh_error_raise branch August 14, 2025 14:50
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants