fix: oidc server error to http status mapping#865
Merged
Conversation
muhlemmer
reviewed
Apr 8, 2026
Comment on lines
+225
to
+257
| func mapVerifierError(err error, description string) error { | ||
| oidcErr := new(Error) | ||
| if ok := errors.As(err, &oidcErr); ok { | ||
| return err | ||
| } | ||
| switch { | ||
| case errors.Is(err, ErrParse): | ||
| err = ErrInvalidRequest().WithParent(err).WithDescription("%s", description) | ||
| case errors.Is(err, ErrIssuerInvalid), | ||
| errors.Is(err, ErrSubjectMissing), | ||
| errors.Is(err, ErrAudience), | ||
| errors.Is(err, ErrAzpMissing), | ||
| errors.Is(err, ErrAzpInvalid), | ||
| errors.Is(err, ErrSignatureMissing), | ||
| errors.Is(err, ErrSignatureMultiple), | ||
| errors.Is(err, ErrSignatureUnsupportedAlg), | ||
| errors.Is(err, ErrSignatureInvalidPayload), | ||
| errors.Is(err, ErrSignatureInvalid), | ||
| errors.Is(err, ErrExpired), | ||
| errors.Is(err, ErrIatMissing), | ||
| errors.Is(err, ErrIatInFuture), | ||
| errors.Is(err, ErrIatToOld), | ||
| errors.Is(err, ErrNonceInvalid), | ||
| errors.Is(err, ErrAcrInvalid), | ||
| errors.Is(err, ErrAuthTimeNotPresent), | ||
| errors.Is(err, ErrAuthTimeToOld), | ||
| errors.Is(err, ErrAtHash): | ||
| err = ErrInvalidGrant().WithParent(err).WithDescription("%s", description) | ||
| case errors.Is(err, ErrDiscoveryFailed): | ||
| err = ErrServerError().WithParent(err).WithDescription("%s", description) | ||
| } | ||
| return err | ||
| } |
Collaborator
There was a problem hiding this comment.
I think we can inline this code into DefaultToServerError. There's another errors.As asserting the type Error type there, we can remove that.
I think we also need to add default to the case switch which still creates a server error as default.
|
🎉 This PR is included in version 3.47.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
|
thank you 🙏 - we've consumed the change and it working as expected. |
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.
This PR maps
OIDC server errorstoHTTP Status 500Additional changes: Map verifier errors to appropriate OIDC errors to prevent mapping the generic verifier errors to OIDC server error by default.
Closes #852