Fix automation tag filters to use AND logic instead of OR#22365
Draft
devin-ai-integration[bot] wants to merge 1 commit into
Draft
Fix automation tag filters to use AND logic instead of OR#22365devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…ts for AND logic Previously, selecting multiple tags in the automation trigger UI produced a single match_related object with all tag IDs in an array, which the backend evaluates as OR (match any tag). This was misleading since the UI presents tags as additive filters. Now, each tag produces its own match_related object in an array, which the backend evaluates as AND (match all tags). Flows still use a single object with an array of IDs (OR) since selecting multiple flows means 'any of these'. Co-authored-by: Nate <nate@prefect.io> Co-Authored-By: Nate Nowack <nate@prefect.io>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When multiple tags are selected in the automation trigger UI, the UI serializes them as a single
match_relatedobject with all tag IDs in an array:{ "match_related": { "prefect.resource.role": "tag", "prefect.resource.id": ["prefect.tag.X", "prefect.tag.alerting_on"] } }The backend evaluates this as OR (match any of these tags), but the UI presents tags as additive filters, implying AND logic. This is a UX gotcha reported by users.
Fix
buildMatchRelated()now produces separatematch_relatedobjects per tag:{ "match_related": [ { "prefect.resource.role": "tag", "prefect.resource.id": "prefect.tag.X" }, { "prefect.resource.role": "tag", "prefect.resource.id": "prefect.tag.alerting_on" } ] }The backend already evaluates an array of
match_relatedobjects as AND (all(match.includes(related) for match in match_related)).Flow selection is unchanged — multiple flows still use a single object with an array of IDs (OR: match any of these flows), which is the correct semantic for "runs of flow A or flow B".
Files changed:
automation-schema.ts—match_relatedtype now acceptsResourceSpecification | ResourceSpecification[]flow-run-state-trigger-fields.tsx—buildMatchRelated()emits array for tags; extractors handle both formatsuse-edit-automation.ts— Preserves arraymatch_relatedfrom API instead of collapsing to first elementcustom-trigger-fields.tsx— Handles arraymatch_relatedtype safelyChecklist
<link to issue>"mint.json.Link to Devin session: https://app.devin.ai/sessions/4da47f4177f844f6b9d33d0953d69a35
Requested by: @zzstoatzz