[WIP] Fix client handling of 400 errors in PKCE#43
Merged
Conversation
Changed the request method to resolve (not reject) when receiving a 400 Bad Request error. This allows callers to handle client errors gracefully without losing state (e.g., PKCE code verifier). Callers can check response.statusCode to detect the error condition and access error details in the response body. - 200-299: Success - resolves with deserialized body - 400: Client error - resolves with raw error body - 401-599: Other errors - rejects with HttpError This prevents state loss when 400 errors occur in OAuth/PKCE flows. Co-authored-by: Subterrane <5290140+Subterrane@users.noreply.github.com>
Copilot stopped work on behalf of
Subterrane due to an error
November 22, 2025 00:01
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.
Fix 400 Error Handling in OneLogin Node SDK
The SDK currently rejects all HTTP responses with status codes outside the 200-299 range, including 400 (Bad Request) errors. This causes issues when:
Plan:
requestmethoddefaultApi.tsrequest method to resolve (not reject) on 400 errors{ response, body }instead of rejecting with HttpErrorresponse.statusCode === 400to detect errorsSummary
Changes Made
Modified
api/defaultApi.ts(lines 254-260) to handle 400 Bad Request errors without rejecting the promise.Before:
After:
Rationale
When a 400 error occurs in OAuth/PKCE flows, the previous implementation would reject the promise, causing catch blocks to execute and potentially clear important state (like the code verifier) before the error could be properly handled. This fix allows callers to handle 400 errors gracefully by checking
response.statusCodeand accessing error details inresponse.body.Testing
Security Summary
No vulnerabilities found by CodeQL security scanner.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.