Repository navigation
Conversation
This was referenced Nov 12, 2026
Consolidates the previously separate drafts #127797 and #127812 into one review unit; the code is unchanged from those individually validated drafts. - social auth copies the request-token and auth extra-argument settings before mutating them with request data - oauth2 decodes form-encoded token response bodies before parsing form values Integrated in #130956.
joshuarli
force-pushed
the
josh/typing-bundle/auth
branch
from
November 26, 2026 00:01
6a6edf1 to
aabe111
Compare
Comment on lines
127
to
+128
| if req.headers["Content-Type"].startswith("application/x-www-form-urlencoded"): | ||
| return dict(parse_qsl(cast(Any, body))) | ||
| return dict(parse_qsl(body.decode("utf-8"))) |
Contributor
There was a problem hiding this comment.
exchange_token KeyErrors when token response omits Content-Type
Use req.headers.get("Content-Type", "") before startswith; a missing header raises KeyError and aborts SSO. The identity OAuth path already does this.
Evidence
exchange_tokendoesreq.headers["Content-Type"].startswith(...)on the external token response.safe_urlopen/requestsresponses do not guarantee aContent-Typeheader.- Missing header raises
KeyErrorbefore form or JSON parsing. - Parallel path in
identity/oauth2.pyusesreq.headers.get("Content-Type", "").lower().
Identified by Warden · sentry-backend-bugs · YME-8BT
Comment on lines
129
to
130
| data = orjson.loads(body) | ||
| return data |
Contributor
There was a problem hiding this comment.
exchange_token leaves orjson.loads failures uncaught
Wrap orjson.loads(body) in try/except JSONDecodeError and surface a pipeline error; non-JSON IdP bodies currently crash token exchange.
Evidence
- Non-form branch calls bare
orjson.loads(body)on the external response body. - IdP error pages or wrong content types can be HTML/plain text, not JSON.
- No local handler;
JSONDecodeErrorpropagates out ofdispatch→exchange_token. identity/oauth2.pycatchesorjson.JSONDecodeErrorand returns a controlled error payload.
Identified by Warden · sentry-backend-bugs · 2XB-5GN
This branch has not been deployed
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.
Combines two typing-campaign drafts into one review unit; the code is unchanged from the individually validated drafts.
Integrated in #130956.