fix: prevent query params leaking into typed session dict#854
Open
temrjan wants to merge 1 commit intoAnswerDotAI:mainfrom
Open
fix: prevent query params leaking into typed session dict#854temrjan wants to merge 1 commit intoAnswerDotAI:mainfrom
temrjan wants to merge 1 commit intoAnswerDotAI:mainfrom
Conversation
When a session parameter is type-hinted as `dict`, the `anno is dict` check in `_find_p` returned the contaminated `data` dict (which includes merged query params from `_find_ps`) before the session name check could run. Move the session name check before `anno is dict` so that `session: dict` correctly returns `conn.scope['session']` instead of the request data. Also fix the existing `test_get_toaster_with_typehint` test which was failing on main due to this bug (missing toast setup step). Closes AnswerDotAI#845 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes #845
When a session parameter is type-hinted as
dict, query parameters from the request leak into the session, eventually causing the session cookie to exceed its size limit and get cleared on every request.Root Cause
In
_find_p, the checkif anno is dict: return data(line 201) runs before the session name check on line 203. Since_find_psmerges query params intodataviadata |= dict(conn.query_params), returningdataforsession: dictincludes all query parameters.Fix
Move the session name check before
anno is dict:Test Plan
test_get_toaster_with_typehint(was failing on main)test_session_dict_no_query_param_leakregression test🤖 Generated with Claude Code