Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(issues): Fix 9-15 character hex parameterization and add tests
  • Loading branch information
mrduncan committed Jun 20, 2025
commit 92be6c829233e9151e96c6b47b55f820e57153b3
7 changes: 4 additions & 3 deletions src/sentry/grouping/parameterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,10 @@ def compiled_pattern(self) -> re.Pattern[str]:
# least one number it must contain at least one a-f otherwise it
# would have matched "int".
#
# (?=.*[0-9]): At least one 0-9 is in the 16 match.
# [0-9a-f]{16}: Exactly 16 hex characters (0-9, a-f).
(\b(?=.*[0-9])[0-9a-f]{8,16}\b)
# (?=.*[0-9]): At least one 0-9 is in the match.
# [0-9a-f]{8/16}: Exactly 8 or 16 hex characters (0-9, a-f).
(\b(?=.*[0-9])[0-9a-f]{8}\b) |
(\b(?=.*[0-9])[0-9a-f]{16}\b)
""",
)
if r.name == "hex"
Expand Down
15 changes: 10 additions & 5 deletions tests/sentry/grouping/test_parameterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ def parameterizer():
("hex", """blah 0x9af8c3b had a problem""", """blah <hex> had a problem"""),
("hex", """blah 9af8c3b0 had a problem""", """blah <hex> had a problem"""),
("hex", """blah 9af8c3b09af8c3b0 had a problem""", """blah <hex> had a problem"""),
(
"hex - missing numbers",
"""blah aaffccbb had a problem""",
"""blah aaffccbb had a problem""",
),
(
"hex - not 4 or 8 bytes",
"""blah 4aaa 9aaaaaaaa 10aaaaaaaa 15aaaaaaaaaaaaa 17aaaaaaaaaaaaaaa had a problem""",
"""blah 4aaa 9aaaaaaaa 10aaaaaaaa 15aaaaaaaaaaaaa 17aaaaaaaaaaaaaaa had a problem""",
),
("float", """blah 0.23 had a problem""", """blah <float> had a problem"""),
("int", """blah 23 had a problem""", """blah <int> had a problem"""),
(
Expand Down Expand Up @@ -150,11 +160,6 @@ def parameterizer():
"""A quick brown fox jumped over the lazy dog""",
"""A quick brown fox jumped over the lazy dog""",
),
(
"Not confidently a hex",
"""blah aaffccbb had a problem""",
"""blah aaffccbb had a problem""",
),
],
)
def test_parameterize_standard(name, input, expected, parameterizer):
Expand Down
Loading