Repository navigation
fix(oauth): raise /oauth/callback code max_length 2048 -> 4096 - #7129
Open
ToniAdreal wants to merge 1 commit into
Open
ToniAdreal wants to merge 1 commit into
ToniAdreal wants to merge 1 commit into
Conversation
ToniAdreal
requested review from
Lang-Akshay,
brian-hussey,
crivetimihai,
ja8zyjits and
msureshkumar88
as code owners
October 5, 2026 09:45
ToniAdreal
force-pushed
the
fix-oauth-code-max-length
branch
from
October 5, 2026 14:48
33f7794 to
bdc885c
Compare
Open
1 of 6 tasks
Some providers (long session-bound codes) exceed 2048 chars and get a 422 from FastAPI query validation before the handler ever runs. This matches the 4096 cap already used by the SSO callback router. Fixes IBM#7068 Signed-off-by: Toni Adreal <184365500+ToniAdreal@users.noreply.github.com>
ToniAdreal
force-pushed
the
fix-oauth-code-max-length
branch
from
October 25, 2026 09:10
bdc885c to
2aa22b4
Compare
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.
Problem
Fixes #7068.
Some providers return long, session-bound authorization codes that exceed 2048 characters. The
/oauth/callbackendpoint rejects those with 422 Unprocessable Entity from FastAPI query validation — before the handler ever runs — so users can't complete the OAuth flow and there's no way to reach the handler's real validation.Repro (verified locally)
Using FastAPI
TestClientwithget_dboverridden against the callback endpoint:max_length=4096→ 400"Invalid OAuth state parameter."(reaches the handler, which correctly reports the bad state)This isolates the 2048 cap as the sole cause of the 422.
Change
One line in
mcpgateway/routers/oauth_router.py:No DB migration needed (query param only). This also aligns with the existing precedent in this repo:
routers/sso.pyalready usesmax_length=4096for the SSO callback's authorization code.Risk
Minimal — only widens a length cap; downstream token exchange and HMAC state verification still do the real validation.