Fix 500 error when AI tab encounters a 401 from the runtime#8958
Open
ericpgreen2 wants to merge 3 commits intomainfrom
Open
Fix 500 error when AI tab encounters a 401 from the runtime#8958ericpgreen2 wants to merge 3 commits intomainfrom
ericpgreen2 wants to merge 3 commits intomainfrom
Conversation
When `getFeatureFlags` fails (e.g. due to an expired runtime JWT), the unhandled rejection propagated to SvelteKit's default `handleError`, which rendered a generic "Internal Error" page. Now the error is caught and feature flags fall back to defaults, letting the page render.
The `JWT` interface requires `receivedAt` for computing token expiry in `maybeWaitForFreshJWT`. Without it, the expiry calculation produces `NaN`, which can cause the freshness check to silently misbehave.
Previously only `"auth token is expired"` got a specific 401 message; any other 401 fell through to the generic "Sorry, something went wrong!" fallback. Now all 401s show a clear "Authentication error" message suggesting a page refresh.
AdityaHegde
approved these changes
Mar 6, 2026
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.
getFeatureFlagsin the AI route's load function so a runtime 401 doesn't propagate as an unhandled exception (which SvelteKit renders as a generic "Internal Error" page)receivedAton the JWT object infetchProjectDeploymentDetailssomaybeWaitForFreshJWTcan correctly compute token expirycreateUserFacingErrorso any 401 that does reach the error page shows "Authentication error" instead of "Sorry, something went wrong!"Reported in Slack
Checklist:
Developed in collaboration with Claude Code