fix: keep blank-valued query params significant in query_string_matcher - #804
Conversation
query_string_matcher parsed both the request and the configured query with parse_qsl()'s default keep_blank_values=False, so a parameter with an empty value (b=, or a bare b) was dropped before comparison. As a result ?a=1 matched a request to ?a=1&b=, and a registration that required b= matched a request that omitted it. This auto-applies to any registered URL that carries a query string (via _should_match_querystring), so it silently mismatches on the default path. The request-param parser already uses keep_blank_values=True (__init__.py), so query_param_matcher treats b= as significant — the two query-matching paths disagreed on the same request. Parse both sides with keep_blank_values=True so blanks are compared, not discarded. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #804 +/- ##
==========================================
+ Coverage 99.84% 99.90% +0.06%
==========================================
Files 9 9
Lines 3295 3309 +14
==========================================
+ Hits 3290 3306 +16
+ Misses 5 3 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
In the future, you should remove the LLM checklists and noise from your pull request descriptions. It makes your contributions look like low-quality changes that are likely to be rejected by open source projects. |
|
Thanks Mark, that's fair — I've trimmed the description down to just the bug and the fix. I also corrected the disclosure line: this was AI-authored end to end, so I shouldn't have worded it as if I'd run the tests by hand. |
query_string_matcherparses both the incoming request query and the configured query withparse_qsl()at its defaultkeep_blank_values=False, so any empty-valued parameter (b=, or a bareb) is dropped before comparison:This matcher is auto-added for any registered URL carrying a query string (
BaseResponse._should_match_querystring), so blank params are silently ignored on both sides of the default path:It's also inconsistent with the request-param parser in
responses/__init__.py, which useskeep_blank_values=True— sorequest.paramsand the explicitquery_param_matcheralready treatb=as a real parameter.Fix: parse both sides of
query_string_matcherwithkeep_blank_values=True. Addedtest_query_string_matcher_blank_values(fails onmaster, passes with this change).Disclosure: fully AI-authored (Claude Code, autonomous) — an AI wrote the change and ran the tests; the account operator did not hand-review the diff.