Skip to content

feat(preprod): Hook size analysis detector to diff#108209

Draft
chromy wants to merge 1 commit intochromy/2026-03-12-add-grouptypefrom
chromy/2026-03-12-hook-detector-to-diff-task
Draft

feat(preprod): Hook size analysis detector to diff#108209
chromy wants to merge 1 commit intochromy/2026-03-12-add-grouptypefrom
chromy/2026-03-12-hook-detector-to-diff-task

Conversation

@chromy
Copy link
Contributor

@chromy chromy commented Feb 13, 2026

Replace direct Kafka occurrence production with the workflow engine's
DataPacket pipeline. maybe_emit_issues() now looks up
SizeAnalysisSubscriptions for the project and feeds size deltas into
process_data_packet(), which resolves linked detectors and evaluates
them instead of using a hardcoded threshold.

PRs:

Design doc

@chromy chromy requested review from a team as code owners February 13, 2026 11:33
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 13, 2026
@github-actions
Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/preprod/migrations/0027_size_analysis_subscription.py

for 0027_size_analysis_subscription in preprod

--
-- Create model SizeAnalysisSubscription
--
CREATE TABLE "sentry_sizeanalysissubscription" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "project_id" bigint NOT NULL);
ALTER TABLE "sentry_sizeanalysissubscription" ADD CONSTRAINT "sentry_sizeanalysiss_project_id_41e3355e_fk_sentry_pr" FOREIGN KEY ("project_id") REFERENCES "sentry_project" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_sizeanalysissubscription" VALIDATE CONSTRAINT "sentry_sizeanalysiss_project_id_41e3355e_fk_sentry_pr";
CREATE INDEX CONCURRENTLY "sentry_sizeanalysissubscription_project_id_41e3355e" ON "sentry_sizeanalysissubscription" ("project_id");

@chromy chromy marked this pull request as draft February 13, 2026 11:45
@chromy chromy changed the base branch from master to chromy/2026-03-12-add-grouptype February 13, 2026 11:46
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

def validate_data_sources(self, value: list[Any]) -> list[Any]:
if not value:
raise serializers.ValidationError("At least one data source is required")
return value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation bypass when dataSources field is omitted entirely

Low Severity

The validate_data_sources method enforces "at least one data source is required," but because the data_sources field is declared with required=False, DRF never calls validate_data_sources when the field is omitted entirely from the request. Only an explicitly empty list (dataSources: []) is caught. Omitting dataSources altogether allows creating a detector with no data sources, making it non-functional since no subscriptions or data sources would exist to trigger it.

Fix in Cursor Fix in Web

extra={
"subscription_id": subscription.id,
"detector_count": len(results),
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameter base_metric is now unused after refactoring

Low Severity

The base_metric parameter is accepted by both maybe_emit_issues and _maybe_emit_issues but is never read in the new function body. The old code passed it to diff_to_occurrence for artifact metadata, but after the refactoring to use process_data_packet, only head_metric is used (to derive the project). This leaves base_metric as dead code in the function signature and at the call site.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant