From fb4f2ae52d26d40ae5430cf9fc389390e94fca87 Mon Sep 17 00:00:00 2001 From: Alexandre Chakroun Date: Thu, 28 Mar 2024 21:37:50 +0100 Subject: [PATCH] Filter in-app frames to decide for CODEOWNERS --- src/sentry/ownership/grammar.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/sentry/ownership/grammar.py b/src/sentry/ownership/grammar.py index 7696d2391f2767..6f17a2a322c7be 100644 --- a/src/sentry/ownership/grammar.py +++ b/src/sentry/ownership/grammar.py @@ -116,12 +116,11 @@ def dump(self) -> Mapping[str, str]: def load(cls, data: Mapping[str, str]) -> Matcher: return cls(data["type"], data["pattern"]) - @staticmethod - def munge_if_needed(data: PathSearchable) -> tuple[Sequence[Mapping[str, Any]], Sequence[str]]: + def munge_if_needed(self, data: PathSearchable) -> tuple[Sequence[Mapping[str, Any]], Sequence[str]]: keys = ["filename", "abs_path"] platform = data.get("platform") sdk_name = get_sdk_name(data) - frames = find_stack_frames(data) + frames = self.find_in_app_stack_frames(data) if platform: munged = munged_filename_and_frames(platform, frames, "munged_filename", sdk_name) if munged: @@ -130,13 +129,17 @@ def munge_if_needed(data: PathSearchable) -> tuple[Sequence[Mapping[str, Any]], return frames, keys + @staticmethod + def find_in_app_stack_frames(data: PathSearchable) -> Sequence[Mapping[str, Any]]: + return [frame for frame in find_stack_frames if frame.get("in_app")] + def test(self, data: PathSearchable) -> bool: if self.type == URL: return self.test_url(data) elif self.type == PATH: return self.test_frames(*self.munge_if_needed(data)) elif self.type == MODULE: - return self.test_frames(find_stack_frames(data), ["module"]) + return self.test_frames(self.find_in_app_stack_frames(data), ["module"]) elif self.type.startswith("tags."): return self.test_tag(data) elif self.type == CODEOWNERS: