fix(gotrue): OAuth server throws FormatException instead of ArgumentE…#1535
Merged
Merged
Conversation
spydon
approved these changes
Jul 6, 2026
spydon
left a comment
Contributor
There was a problem hiding this comment.
This is technically a breaking change, but I think we can let it slip.
Contributor
Author
|
Indeed, the signature changes so it makes sense to make it a breaking change. I can change the commit to mark it as breaking since the automatic checks are failing as well on the commit message? |
Contributor
It's failing because the first letter is capital, we really should remove the casing check 😅 |
spydon
pushed a commit
that referenced
this pull request
Jul 7, 2026
…1536) > Stacked on #1535. Review/merge that one first. ## What kind of change does this PR introduce? Bug fix ## What is the current behavior? `getAuthorizationDetails` crashed with a `FormatException` when the OAuth 2.1 server short-circuited the consent flow. This happens when a user who already approved a client starts a new authorization for it: the server returns a redirect-only body (`{"redirect_url": "...?code=..."}`) with no user or client, which the parser rejected because it required a user object. ## What is the new behavior? `getAuthorizationDetails` now checks whether a `redirect_url` is present returning `OAuthAuthorizationRedirectResponse` when it is present. When the key isn't present the old `OAuthAuthorizationDetailsResponse` object is returned. Callers now switch on the result and forward the redirect instead of losing it to an exception. Genuinely malformed detail bodies (no redirect_url and no user) still throw, so validation isn't weakened. ## Additional context BREAKING CHANGE: `getAuthorizationDetails` now returns the sealed `OAuthAuthorizationResponse` instead of `OAuthAuthorizationDetailsResponse`. Callers must switch/cast to access client, user, scope and redirectUri.
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.
What kind of change does this PR introduce?
As mentioned in this discussion for #1499, the
OAuthAuthorizationDetailsResponse.fromJsonbest throws aFormatExceptionto be inline with the rest of the codebase.What is the current behavior?
Currently, when a JSON without a
userkey is parsed by theOAuthAuthorizationDetailsResponse.fromJsonfactory, the factory throws anArgumentError.What is the new behavior?
Now, when a JSON without a
userkey is parsed by theOAuthAuthorizationDetailsResponse.fromJsonfactory, thefactory throws a
FormatException.Additional context
@spydon from the discussion I had the idea that you updated this, but I haven't found any related changes, so I've made a small PR to fix this.