Skip to content

fix: compare opaque fragment identifiers verbatim - #806

Merged
markstory merged 2 commits into
getsentry:masterfrom
chuenchen309:fix/fragment-identifier-opaque
Jul 21, 2026
Merged

fix: compare opaque fragment identifiers verbatim#806
markstory merged 2 commits into
getsentry:masterfrom
chuenchen309:fix/fragment-identifier-opaque

Conversation

@chuenchen309

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • Bug Fix

Description

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 registered for #/users/5
therefore also matched #/users/6, #section2, and URLs with no fragment.

This only runs the order-insensitive parse_qsl comparison when the identifier
is query-string-style (contains =); otherwise it compares the fragment
strings verbatim. Key=value fragments are unaffected.

Related Issues

None.

PR checklist

  • Read the contributing guidelines
  • Ran the matcher tests and black / isort / flake8 locally (all clean)
  • Added an entry to the CHANGES file

Added/updated tests?

  • Yes — test_fragment_identifier_matcher_opaque fails on main (the
    matcher accepts #/users/6) and passes with this change; the full
    test_matchers.py suite 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 test
first, 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.

`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>
@chuenchen309
chuenchen309 requested a review from markstory as a code owner July 19, 2026 02:46
@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.90%. Comparing base (aae1d47) to head (40287a0).
⚠️ Report is 4 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@markstory
markstory merged commit 2af69cb into getsentry:master Jul 21, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants