Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions src/sentry/ownership/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ def test_url(self, data):

def test_frames(self, data, keys):
for frame in _iter_frames(data):
value = next((frame.get(key) for key in keys if frame.get(key)), None)

if not value:
continue
for key in keys:
value = frame.get(key)
if not value:
continue

if glob_match(value, self.pattern, ignorecase=True, path_normalize=True):
return True
if glob_match(value, self.pattern, ignorecase=True, path_normalize=True):
return True

return False

Expand Down
13 changes: 13 additions & 0 deletions tests/sentry/models/test_projectownership.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,19 @@ def test_get_autoassign_owners_when_codeowners_and_issueowners_exists(self):
self.project.id, {"stacktrace": {"frames": [{"filename": "src/foo.py"}]}}
) == (True, [self.user, self.team], False)

def test_abs_path_when_filename_present(self):
frame = {
"filename": "computer.cpp",
"abs_path": "C:\\My\\Path\\computer.cpp",
}
rule = Rule(Matcher("path", "*My\\Path*"), [Owner("team", self.team.slug)])
ProjectOwnership.objects.create(
project_id=self.project.id, schema=dump_schema([rule]), fallthrough=True
)
assert ProjectOwnership.get_owners(
self.project.id, {"stacktrace": {"frames": [frame]}}
) == ([ActorTuple(self.team.id, Team)], [rule])


class ResolveActorsTestCase(TestCase):
def test_no_actors(self):
Expand Down
19 changes: 19 additions & 0 deletions tests/sentry/ownership/test_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@ def test_matcher_test_exception():
assert not Matcher("path", "*.py").test({})


def test_matcher_file_abs_path_same_frame():
data = {
"exception": {
"values": [
{
"stacktrace": {
"frames": [
{"filename": "foo/file.py", "abs_path": "/usr/local/src/other/app.py"},
]
}
}
]
}
}

assert Matcher("path", "/usr/local/src/*/app.py").test(data)
assert Matcher("path", "*local/src/*").test(data)


def test_matcher_test_stacktrace():
data = {
"stacktrace": {
Expand Down