Skip to content

Fix automation tag filters to use AND logic instead of OR#22365

Draft
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782313909-fix-automation-tag-filter-and-logic
Draft

Fix automation tag filters to use AND logic instead of OR#22365
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782313909-fix-automation-tag-filter-and-logic

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

When multiple tags are selected in the automation trigger UI, the UI serializes them as a single match_related object 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 separate match_related objects 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_related objects 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.tsmatch_related type now accepts ResourceSpecification | ResourceSpecification[]
  • flow-run-state-trigger-fields.tsxbuildMatchRelated() emits array for tags; extractors handle both formats
  • use-edit-automation.ts — Preserves array match_related from API instead of collapsing to first element
  • custom-trigger-fields.tsx — Handles array match_related type safely
  • Tests and stories updated

Checklist

  • This pull request references any related issue by including "closes <link to issue>"
    • This addresses a UX issue reported via internal Slack: automation tag filters producing OR instead of AND logic
  • If this pull request adds new functionality, it includes unit tests that cover the changes
  • If this pull request removes docs files, it includes redirect settings in mint.json.
  • If this pull request adds functions or classes, it includes helpful docstrings.

Link to Devin session: https://app.devin.ai/sessions/4da47f4177f844f6b9d33d0953d69a35
Requested by: @zzstoatzz

…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>
@zzstoatzz zzstoatzz self-assigned this Jun 24, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring
@github-actions github-actions Bot added the ui-replatform Related to the React UI rewrite label Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ui-replatform Related to the React UI rewrite

1 participant