Skip to content

feat(aci): Add ability to filter workflows by connected detectors#105695

Merged
malwilley merged 3 commits intomasterfrom
sentry-scratch
Jan 6, 2026
Merged

feat(aci): Add ability to filter workflows by connected detectors#105695
malwilley merged 3 commits intomasterfrom
sentry-scratch

Conversation

@malwilley
Copy link
Copy Markdown
Member

Adds the ability to do /organizations/org-slug/workflows/?detector=1&detector=2 which will return workflows connected to either of those two detectors.

@malwilley malwilley requested a review from a team as a code owner January 5, 2026 23:19
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 5, 2026
detector_ids = [int(id) for id in raw_detectorlist]
except ValueError:
raise ValidationError({"detector": ["Invalid detector ID format"]})
queryset = queryset.filter(detectorworkflow__detector_id__in=detector_ids).distinct()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's also add a filter here for the users organization -- that way we can prevent any possible security issues where a user asks for a detector not part of their org.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We are already adding the org filter at the top of filter_workflows

queryset: QuerySet[Workflow] = Workflow.objects.filter(organization_id=organization.id)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah, i didn't notice it was the same queryset 👍

assert len(response3.data) == 2
assert {self.workflow.name, self.workflow_two.name} == {w["name"] for w in response3.data}

def test_filter_by_detector(self) -> None:
Copy link
Copy Markdown
Contributor

@saponifi3d saponifi3d Jan 5, 2026

Choose a reason for hiding this comment

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

thoughts on adding a test case for selecting a detector not part of your org and ensure it returns the correct status codes? (my guess is we'd either want to 401 or 404)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can add a test case for it certainly. I think the current behavior is correct (which is that it will just return an empty list)

@malwilley malwilley requested a review from saponifi3d January 6, 2026 00:01
@malwilley malwilley enabled auto-merge (squash) January 6, 2026 00:19
@malwilley malwilley merged commit d4cd486 into master Jan 6, 2026
65 checks passed
@malwilley malwilley deleted the sentry-scratch branch January 6, 2026 00:24
@github-actions github-actions bot locked and limited conversation to collaborators Jan 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants