fix(server): handle OIDC token exchange errors gracefully & fix debug log modal#7673
fix(server): handle OIDC token exchange errors gracefully & fix debug log modal#7673adambenhassen wants to merge 8 commits intomainfrom
Conversation
Summary of ChangesHello @adambenhassen, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the robustness and user experience of OIDC authentication by transforming cryptic server errors into clear, actionable messages. Instead of generic 500 errors, users will now receive specific guidance when OIDC token exchanges fail, such as due to expired client secrets or network issues. This change improves diagnosability for administrators while maintaining security by preventing sensitive information leakage. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
2967daf to
3ed7fe6
Compare
There was a problem hiding this comment.
Code Review
This pull request effectively addresses the issue of unhandled OIDC token exchange errors by introducing a try-catch block to gracefully handle them. The new describeOIDCSignInError function provides clear, user-safe error messages, and it is well-covered by a comprehensive set of unit tests. I have one suggestion to improve the readability of the error description logic, aligning with our guidelines to prioritize readability.
|
🐋 This PR was built and pushed to the following Docker images: Targets: Platforms: Image Tag: |
💻 Website PreviewThe latest changes are available as preview in: https://pr-7673.hive-landing-page.pages.dev |
jdolle
left a comment
There was a problem hiding this comment.
There error messages are great. This is a major improvement.
I'd feel better if we had more defined error codes rather than relying on the error messages. Otherwise
Minor: Where appropriate, we might also want to mention the OIDC Logs we expose in the settings. These often help people resolve issues with their OIDC provider/config.
| export function describeOIDCSignInError(error: unknown): string { | ||
| const message = error instanceof Error ? error.message : String(error); | ||
|
|
||
| if (message.includes('invalid_client')) { |
There was a problem hiding this comment.
generally I try to avoid matching on message text. Are there any other fields we can match on that have more guarantees than the message?
There was a problem hiding this comment.
Valid concern in general, but I've investigated the supertokens source and exchangeAuthCodeForOAuthTokens throws plain Error objects with this format {"error":"invalid_client","error_description":"..."}
There are no structured fields (error.code, typed subclasses, etc..), everything is embedded in the message string. the OAuth2 error codes (invalid_client, invalid_grant, etc) only exist inside the stringified response body within the message.
| } | ||
|
|
||
| if (message.includes('Could not find OIDC integration')) { | ||
| return 'The OIDC integration could not be found. It may have been removed or misconfigured. Please contact your organization administrator.'; |
There was a problem hiding this comment.
why contact org admin instead of review your OIDC integration settings here?
There was a problem hiding this comment.
On a note we should also consider that this is end user facing, people seeing this might not even have access to OIDC settings. So I think it might be okay to say, something like "please contact your organization admin about the OIDC configuration"?
b506780 to
c7f88cb
Compare
c7f88cb to
17e5c71
Compare
17e5c71 to
b82a531
Compare
b82a531 to
7d8be22
Compare


Background
OIDC token exchange errors (i.e. expired Azure AD client secret) cause unhandled 500 responses instead of actionable user-facing messages.
Description
Catches OIDC sign-in errors and returns a
GENERAL_ERRORwith a user-safe message classified by OAuth 2.0 error code (RFC 6749 5.2), network failure type, or userinfo endpoint error. Full errors are still logged server-side.This PR also fixes the broken debug modal not displaying the log area.
Closes CONSOLE-1794