-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix(stacktrace-link): Use new Java logic #90415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,6 +5,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
from collections.abc import Mapping, Sequence | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
from typing import Any, NamedTuple | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
from sentry import features | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
from sentry.integrations.models.repository_project_path_config import RepositoryProjectPathConfig | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
from sentry.integrations.source_code_management.repo_trees import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RepoAndBranch, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -386,6 +387,7 @@ def convert_stacktrace_frame_path_to_source_path( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
code_mapping: RepositoryProjectPathConfig, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
platform: str | None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sdk_name: str | None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
organization: Organization | None = None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) -> str | None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Applies the given code mapping to the given stacktrace frame and returns the source path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -403,6 +405,17 @@ def convert_stacktrace_frame_path_to_source_path( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
try_munge_frame_path(frame=frame, platform=platform, sdk_name=sdk_name) or frame.filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
has_new_logic = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
features.has("organizations:java-frame-munging-new-logic", organization, actor=None) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if organization | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
else False | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if has_new_logic and platform == "java" and frame.module and frame.abs_path: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
try: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
_, stacktrace_path = get_path_from_module(frame.module, frame.abs_path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
sentry/src/sentry/issues/auto_source_code_config/code_mapping.py Lines 578 to 614 in c86f666
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
except Exception: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logger.warning("Investigate. Falling back to old logic.", exc_info=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if stacktrace_path and stacktrace_path.startswith(code_mapping.stack_root): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stacktrace_path.replace(stack_root, code_mapping.source_root, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,7 +153,7 @@ def get(self, request: Request, project: Project) -> Response: | |
scope = Scope.get_isolation_scope() | ||
|
||
set_top_tags(scope, project, ctx, len(configs) > 0) | ||
result = get_stacktrace_config(configs, ctx) | ||
result = get_stacktrace_config(configs, ctx, project.organization) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it possible for a project to not have an organization? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it's not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha, small nit — no need for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MichaelSun48 there's another for the function in commit_context, thus, made it optional. I will patch it up in the next PR (I tried to focus the test changes). |
||
error = result["error"] | ||
src_path = result["src_path"] | ||
# Post-processing before exiting scope context | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
) | ||
from sentry.silo.base import SiloMode | ||
from sentry.testutils.cases import TestCase | ||
from sentry.testutils.helpers import Feature | ||
from sentry.testutils.silo import assume_test_silo_mode | ||
from sentry.utils.event_frames import EventFrame | ||
|
||
|
@@ -533,6 +534,11 @@ def test_convert_stacktrace_frame_path_to_source_path_java_no_source_context(sel | |
"MainFragment.java", | ||
"src/com/example/vu/android/empowerplant/MainFragment.java", | ||
), | ||
( | ||
"com.example.foo.BarImpl$invoke$bazFetch$2", | ||
"Bar.kt", # Notice "Impl" is not included in the module above | ||
"src/com/example/foo/BarImpl.kt", # This is incorrect; the new logic will fix this | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will remove this test case once we have switched over to the new logic. |
||
), | ||
]: | ||
assert ( | ||
convert_stacktrace_frame_path_to_source_path( | ||
|
@@ -544,6 +550,31 @@ def test_convert_stacktrace_frame_path_to_source_path_java_no_source_context(sel | |
== expected_path | ||
) | ||
|
||
def test_convert_stacktrace_frame_path_to_source_path_java_new_logic(self) -> None: | ||
code_mapping = self.create_code_mapping( | ||
organization_integration=self.oi, | ||
project=self.project, | ||
repo=self.repo, | ||
stack_root="com/example/", | ||
source_root="src/com/example/", | ||
automatically_generated=False, | ||
) | ||
with Feature({"organizations:java-frame-munging-new-logic": True}): | ||
assert ( | ||
convert_stacktrace_frame_path_to_source_path( | ||
frame=EventFrame( | ||
filename="Baz.java", | ||
abs_path="Baz.java", # Notice "Impl" is not included in the module below | ||
module="com.example.foo.BazImpl$invoke$bazFetch$2", | ||
), | ||
code_mapping=code_mapping, | ||
platform="java", | ||
sdk_name="sentry.java.android", | ||
organization=self.organization, | ||
) | ||
== "src/com/example/foo/Baz.java" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notice that |
||
) | ||
|
||
def test_convert_stacktrace_frame_path_to_source_path_backslashes(self) -> None: | ||
assert ( | ||
convert_stacktrace_frame_path_to_source_path( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we are satisfied with the new feature, we won't need to pass the organization.