Skip to content

fix(ACI): Validate and allow updating project id for detector#109135

Draft
ceorourke wants to merge 9 commits intomasterfrom
ceorourke/validate-project-update-detector
Draft

fix(ACI): Validate and allow updating project id for detector#109135
ceorourke wants to merge 9 commits intomasterfrom
ceorourke/validate-project-update-detector

Conversation

@ceorourke
Copy link
Member

@ceorourke ceorourke commented Feb 23, 2026

Allow for project updates on a detector and validate that the project belongs to the target organization.

TODO:

@ceorourke ceorourke requested a review from a team as a code owner February 23, 2026 20:39
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 23, 2026
raise serializers.ValidationError({"config": [str(error)]})

if "project_id" in validated_data:
instance.project_id = validated_data["project_id"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Old project config not invalidated on update

High Severity

When a detector's project_id is updated, only the new project's configuration is invalidated by schedule_update_project_config in the MetricIssueValidator. The old project's configuration still references the detector, causing stale data. Both the old and new project configs need invalidation to maintain consistency.

Fix in Cursor Fix in Web

raise serializers.ValidationError({"config": [str(error)]})

if "project_id" in validated_data:
instance.project_id = validated_data["project_id"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Error detector project options not cleared

Medium Severity

When an error detector's project_id is updated, ErrorDetectorValidator.update() applies configuration to the new project's options (like sentry:fingerprinting_rules) but doesn't clear these values from the old project. The old project retains stale configuration that should have been removed when the detector moved away.

Fix in Cursor Fix in Web

raise serializers.ValidationError({"config": [str(error)]})

if "project_id" in validated_data:
instance.project_id = validated_data["project_id"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Monitor project not updated with detector

High Severity

When a cron monitor detector's project_id is updated, the underlying Monitor object's project_id field is not updated to match. This creates an inconsistency where the detector and its associated monitor reference different projects, breaking the relationship between these tightly coupled objects.

Fix in Cursor Fix in Web

raise serializers.ValidationError({"config": [str(error)]})

if "project_id" in validated_data:
instance.project_id = validated_data["project_id"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Detector cache not invalidated on project change

Medium Severity

When a detector's project_id is updated, the cached detector lookups for both old and new projects are not invalidated. The get_default_detector_for_project cache uses (project_id, detector_type) as the key, so the old project's cache still points to a detector that has moved away, while the new project's cache may not reflect the moved detector.

Fix in Cursor Fix in Web

@ceorourke ceorourke requested a review from a team as a code owner February 23, 2026 21:23
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 1 potential issue.

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

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