fix: compare opaque fragment identifiers verbatim - #806
Merged
markstory merged 2 commits intoJul 21, 2026
Conversation
`fragment_identifier_matcher` ran both the required identifier and the request URL fragment through `parse_qsl`. For an opaque fragment such as `/users/5` (no `=`), `parse_qsl` returns `[]`, so any two opaque fragments — or a request with no fragment at all — compared equal. A matcher for `#/users/5` therefore matched `#/users/6`, `#section2`, and URLs with no fragment. Only run the order-insensitive `parse_qsl` comparison when the identifier is query-string-style (contains `=`); otherwise compare the fragment strings verbatim. Key=value fragments are unaffected. 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 #806 +/- ##
==========================================
+ Coverage 99.84% 99.90% +0.06%
==========================================
Files 9 9
Lines 3295 3322 +27
==========================================
+ Hits 3290 3319 +29
+ Misses 5 3 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
markstory
approved these changes
Jul 21, 2026
MateoGreil
pushed a commit
to MateoGreil/python-comwatt-client
that referenced
this pull request
Aug 28, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [responses](https://github.com/getsentry/responses) ([changelog](https://github.com/getsentry/responses/blob/master/CHANGES)) | `==0.26.2` → `==0.26.3` |  |  | --- ### Release Notes <details> <summary>getsentry/responses (responses)</summary> ### [`v0.26.3`](https://github.com/getsentry/responses/blob/HEAD/CHANGES#0263) [Compare Source](getsentry/responses@0.26.2...0.26.3) - Added a `keep_headers` argument to `_recorder.record` and `Recorder.dump_to_file` to preserve named headers (for example `Date`) that are otherwise stripped as verbose defaults, so a signed response can be recorded and later verified. Matching is case-insensitive. See [#​763](getsentry/responses#763) - Fixed the element type exposed by `CallList` so static type checkers infer `Call` values when iterating, indexing, or filtering recorded calls. See [#​722](getsentry/responses#722) - Fixed `query_string_matcher` (and the query matching auto-applied to a registered URL's own query string) discarding blank-valued query params (`b=`), which caused requests with an extra or missing blank param to match incorrectly. See [#​804](getsentry/responses#804) - Fixed `fragment_identifier_matcher` treating opaque fragments (those without `=`, e.g. `/users/5`) as always equal, so a required fragment matched a different one or none at all. See [#​806](getsentry/responses#806) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4zMC4zIiwidXBkYXRlZEluVmVyIjoiNDQuMzAuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Co-authored-by: Renovate Bot <renovate-bot@git.greil.fr> Reviewed-on: https://git.greil.fr/mat/python-comwatt-client/pulls/55
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 type of PR is this?
Description
fragment_identifier_matcherran both the required identifier and the requestURL fragment through
parse_qsl. For an opaque fragment such as/users/5(no
=),parse_qslreturns[], so any two opaque fragments — or a requestwith no fragment at all — compared equal. A matcher registered for
#/users/5therefore also matched
#/users/6,#section2, and URLs with no fragment.This only runs the order-insensitive
parse_qslcomparison when the identifieris query-string-style (contains
=); otherwise it compares the fragmentstrings verbatim. Key=value fragments are unaffected.
Related Issues
None.
PR checklist
black/isort/flake8locally (all clean)Added/updated tests?
test_fragment_identifier_matcher_opaquefails onmain(thematcher accepts
#/users/6) and passes with this change; the fulltest_matchers.pysuite stays green.Disclosure: this change was authored by an AI coding agent (Claude Code) on this
account — it found the bug, reproduced it against
main, wrote the failing testfirst, and confirmed key=value fragments are unaffected. The account holder
reviews every change and is accountable for it. Happy to close if it's not
wanted.