Skip to content

fix(auto_source_config): Remove unintended rules #88952

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

Merged
merged 7 commits into from
Apr 8, 2025
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
23 changes: 23 additions & 0 deletions src/sentry/issues/auto_source_code_config/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,26 @@
"clojure": {"extensions": ["clj", "cljs", "cljc"]},
"groovy": {"extensions": ["groovy"]},
}


# This list needs to be updated when new packages are added to the list
UNINTENDED_RULES = [
"stack.module:akka.** +app",
"stack.module:com.fasterxml.** +app",
"stack.module:com.microsoft.** +app",
"stack.module:com.sun.** +app",
"stack.module:feign.** +app",
"stack.module:io.opentelemetry.** +app",
"stack.module:jdk.** +app",
"stack.module:oauth.** +app",
"stack.module:org.apache.** +app",
"stack.module:org.glassfish.** +app",
"stack.module:org.jboss.** +app",
"stack.module:org.jdesktop.** +app",
"stack.module:org.postgresql.** +app",
"stack.module:org.springframework.** +app",
"stack.module:org.web3j.** +app",
"stack.module:reactor.core.** +app",
"stack.module:scala.** +app",
"stack.module:sun.** +app",
]
22 changes: 22 additions & 0 deletions src/sentry/issues/auto_source_code_config/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
SCMIntegrationInteractionType,
)
from sentry.issues.auto_source_code_config.code_mapping import CodeMapping, CodeMappingTreesHelper
from sentry.issues.auto_source_code_config.constants import UNINTENDED_RULES
from sentry.locks import locks
from sentry.models.organization import Organization
from sentry.models.project import Project
Expand Down Expand Up @@ -78,6 +79,10 @@ def process_event(
if not platform_config.is_supported():
return [], []

# This is a temporary solution to remove unintended rules across the board
if platform_config.creates_in_app_stack_trace_rules():
remove_unintended_rules(project)

frames_to_process = get_frames_to_process(event.data, platform)
if not frames_to_process:
return [], []
Expand Down Expand Up @@ -203,6 +208,23 @@ def create_configurations(
return code_mappings, in_app_stack_trace_rules


def remove_unintended_rules(project: Project) -> None:
"""
Remove unintended rules from the project's automatic grouping enhancements.
"""
key = "sentry:automatic_grouping_enhancements"
in_app_stack_trace_rules = project.get_option(key, default="").split("\n")
if not in_app_stack_trace_rules:
return

# Remove rules that are not in the code mappings
for rule in in_app_stack_trace_rules:
if rule in UNINTENDED_RULES:
in_app_stack_trace_rules.remove(rule)

project.update_option(key, "\n".join(in_app_stack_trace_rules))


def create_code_mapping(
code_mapping: CodeMapping,
repository: Repository | None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,3 +815,19 @@ def test_categorized_frames_are_not_processed(self) -> None:
)
assert dry_run_code_mappings != []
assert in_app_stack_trace_rules != []

@with_feature({"organizations:auto-source-code-config-java-enabled": True})
def test_unintended_rules_are_removed(self) -> None:
"""Test that unintended rules will be removed without affecting other rules"""
key = "sentry:automatic_grouping_enhancements"
# Let's assume that the package was not categorized, thus, we created a rule for it
self.project.update_option(key, "stack.module:akka.** +app\nstack.module:foo.bar.** +app")
# This module is categorized, thus, we won't attempt derivation for it
frame = self.frame(module="com.sun.Activity", abs_path="Activity.java", in_app=False)
event = self.create_event([frame], self.platform)

# The rule will be removed after calling this
process_event(self.project.id, event.group_id, event.event_id)
rules = self.project.get_option(key)
# Other rules are not affected
assert rules.split("\n") == ["stack.module:foo.bar.** +app"]
Loading