Skip to content
Merged
Changes from all commits
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
55 changes: 55 additions & 0 deletions tests/sentry/issues/ownership/test_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,3 +1130,58 @@ def test_convert_schema_to_rules_text() -> None:
)
== "path:*.js #frontend m@robenolt.com\nurl:http://google.com/* #backend\npath:src/sentry/* david@sentry.io\ntags.foo:bar tagperson@sentry.io\ntags.foo:bar baz tagperson@sentry.io\nmodule:foo.bar #workflow\nmodule:foo bar meow@sentry.io\n"
)


@pytest.mark.parametrize(
"pattern, path_details, expected",
[
# Pattern WITHOUT leading slash
# Path WITH leading slash
# Does not match
(
"libs/web/views/index/**",
[
{"filename": "/libs/web/views/index/src/widget-table.component.tsx"},
{"abs_path": "/libs/web/views/index/src/widget-table.component.tsx"},
],
False,
),
# Pattern WITH leading slash
# Path WITH leading slash
# Matches
(
"/libs/web/views/index/**",
[
{"filename": "/libs/web/views/index/src/widget-table.component.tsx"},
{"abs_path": "/libs/web/views/index/src/widget-table.component.tsx"},
],
True,
),
# Pattern WITHOUT leading slash
# Path WITHOUT leading slash
# Matches
(
"libs/web/views/index/**",
[
{"filename": "libs/web/views/index/src/widget-table.component.tsx"},
{"abs_path": "libs/web/views/index/src/widget-table.component.tsx"},
],
True,
),
# Pattern WITH leading slash
# Path WITHOUT leading slash
# Matches
(
"/libs/web/views/index/**",
[
{"filename": "libs/web/views/index/home.tsx"},
{"abs_path": "libs/web/views/index/home.tsx"},
],
True,
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Root Anchoring Logic Inconsistency

The test expects an anchored pattern /libs/web/views/index/** (with leading slash) to match a path without a leading slash libs/web/views/index/home.tsx. This contradicts standard CODEOWNERS semantics where a leading slash anchors the pattern to the repository root, meaning it should only match paths that also start from the root. This creates an asymmetry with the first test case where a pattern without a leading slash doesn't match a path with one, suggesting the expected value should be False instead of True.

Fix in Cursor Fix in Web

],
)
def test_codeowners_leading_slash_matching(
pattern: str, path_details: Sequence[Mapping[str, str]], expected: bool
) -> None:
_assert_matcher(Matcher("codeowners", pattern), path_details, expected)
Loading