Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(error-tracking): respect AI processing approval for severity inference (#121227)

Hugues Pouillotfa40a277dfcf
diff --git a/products/error_tracking/backend/temporal/lifecycle/issue_created/activities.py b/products/error_tracking/backend/temporal/lifecycle/issue_created/activities.py
index bd6fcf245669..12595c7a958d 100644
--- a/products/error_tracking/backend/temporal/lifecycle/issue_created/activities.py
+++ b/products/error_tracking/backend/temporal/lifecycle/issue_created/activities.py
@@ -185,6 +185,8 @@ def _severity_state(inputs: IssueCreatedWorkflowInputs) -> str | SeverityInferen
team = Team.objects.select_related("organization").get(id=inputs.team_id)
except Team.DoesNotExist:
return SeverityInferenceSkipReason.TEAM_MISSING
+ if not team.organization.is_ai_data_processing_approved:
+ return SeverityInferenceSkipReason.AI_DATA_PROCESSING_NOT_APPROVED
event_properties = fetch_event_properties(team, inputs)
stacktrace = render_stacktrace(event_properties, SEVERITY_INFERENCE_MAX_TOKENS)
diff --git a/products/error_tracking/backend/temporal/lifecycle/issue_created/test/test_workflow.py b/products/error_tracking/backend/temporal/lifecycle/issue_created/test/test_workflow.py
index 85980cbae5e0..f76c4df97332 100644
--- a/products/error_tracking/backend/temporal/lifecycle/issue_created/test/test_workflow.py
+++ b/products/error_tracking/backend/temporal/lifecycle/issue_created/test/test_workflow.py
@@ -250,7 +250,14 @@ def _decision(choice: str) -> DecisionResult:
True,
False,
_decision("critical"),
- IssueSeverityInferenceResult(resolved=True, stored_severity="critical"),
+ IssueSeverityInferenceResult(skipped_reason=SeverityInferenceSkipReason.AI_DATA_PROCESSING_NOT_APPROVED),
+ None,
+ ),
+ (
+ True,
+ None,
+ _decision("critical"),
+ IssueSeverityInferenceResult(skipped_reason=SeverityInferenceSkipReason.AI_DATA_PROCESSING_NOT_APPROVED),
None,
),
(
@@ -306,7 +313,7 @@ def test_severity_inference_outcomes(
inference_outcomes: MagicMock,
capture_exception: MagicMock,
enabled: bool,
- ai_approved: bool,
+ ai_approved: bool | None,
decide_outcome: DecisionResult | Exception,
expected_result: IssueSeverityInferenceResult | None,
expected_error_type: str | None,
@@ -343,7 +350,10 @@ def test_severity_inference_outcomes(
inference_outcomes.labels.assert_called_once_with(outcome=expected_outcome, severity=expected_severity)
inference_outcomes.labels.return_value.inc.assert_called_once_with()
capture_exception.assert_not_called()
- if enabled and isinstance(decide_outcome, DecisionResult):
+ if enabled and not ai_approved:
+ fetch_event_properties.assert_not_called()
+ decide.assert_not_called()
+ elif enabled and isinstance(decide_outcome, DecisionResult):
assert decide.call_args.args[0].model == SEVERITY_INFERENCE_MODEL
assert decide.call_args.args[0].privacy_mode is True