Add graceful error handling for SSO configuration and discovery failures#9029
Closed
Add graceful error handling for SSO configuration and discovery failures#9029
Conversation
Copilot
AI
changed the title
[WIP] Update SSO integration for error handling and fallback
Add graceful error handling for SSO configuration and discovery failures
Jan 8, 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.
Problem
SSO integration crashes the server when environment variables are invalid or when the upstream discovery service is unreachable. This prevents graceful fallback to Email OTP authentication.
Fixes FRM-2259
Solution
Breaking Changes
Improvements:
Configuration validation without crashing: Added
isSsoConfigured()that validatesSSO_DISCOVERY_URL,SSO_CLIENT_ID, andSSO_CLIENT_SECRETat startup. Checks for blank values, default placeholders, and invalid URL formats. Logs errors but never throws.Lazy OIDC discovery: Moved discovery from constructor to
initializeClientConfig()method that only executes when SSO is actually used. Prevents startup crashes from unreachable endpoints.Safe error propagation: Wrapped URL parsing in try-catch and discovery calls in promise rejection handlers. All errors converted to Result types via
ResultAsync.fromPromise().Example flow:
Error scenarios now handled:
SSO_DISCOVERY_URLformat → logged, SSO disabled, Email OTP availableBefore & After Screenshots
N/A - Backend changes only
Tests
Deploy Notes
No new environment variables, scripts, or dependencies.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
fastdl.mongodb.org/usr/local/bin/node node --experimental-vm-modules node_modules/jest/bin/jest.js --testPathPattern=auth.service.spec --verbose all')}catch(e){}"(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.