Skip to content

Add deployment filters to flow run triggers#22319

Open
samiat4911 wants to merge 7 commits into
PrefectHQ:mainfrom
samiat4911:codex/8253-deployment-filter-flow-run-triggers
Open

Add deployment filters to flow run triggers#22319
samiat4911 wants to merge 7 commits into
PrefectHQ:mainfrom
samiat4911:codex/8253-deployment-filter-flow-run-triggers

Conversation

@samiat4911

Copy link
Copy Markdown

Summary

Closes #8253
This PR adds deployment filtering to flow run state automation triggers in the React UI.

The backend already supports matching related deployment resources through match_related, but the flow run state trigger form only exposed flow and tag filters. This updates the UI to let users scope flow run state automations to deployments, preserves multi-resource match_related values when editing automations, and shows deployment filters in trigger details.

Changes include:

  • Adds a deployments selector to the flow run state trigger fields
  • Supports match_related as either a single resource spec or an array of resource specs
  • Builds combined flow/tag plus deployment filters as separate related-resource specs
  • Preserves array match_related values in edit mode
  • Updates trigger template detection for deployment-filtered flow run state triggers
  • Displays deployment filters in trigger details
  • Adds tests and stories for the new behavior

Checklist

  • This pull request references any related issue by including "closes #8253"
    • If no issue exists and your change is not a small fix, please create an issue first.
  • 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.

@github-actions github-actions Bot added enhancement An improvement of an existing feature ui Related to the Prefect web interface ui-replatform Related to the React UI rewrite labels Jun 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 94e352dc44

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +271 to +272
return prefectResourceIds.every((value) =>
allowedRelatedResources.some((resource) => value.startsWith(resource)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid treating mixed flow/tag filters as a template

When an existing custom trigger has match_related specs for both prefect.flow.* and prefect.tag.*, this predicate now returns true just because every ID has one of the allowed prefixes. That sends the trigger through the flow-run-state form even though FlowRunStateTriggerFields hides tags whenever flows are selected and its builder assumes only one of flow/tag is present, so changing a flow or deployment rewrites the hidden tag constraint away. The guard should allow deployment to combine with either flow or tag, but not make unsupported flow+tag filters look editable as this template.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@samiat4911 this comment will need to be addressed before we can merge this PR

@samiat4911 samiat4911 Jun 25, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

okay no problem thanks for the feedback

@samiat4911

Copy link
Copy Markdown
Author

hello @desertaxle please can you review the update I just made? thanks

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

Labels

enhancement An improvement of an existing feature ui Related to the Prefect web interface ui-replatform Related to the React UI rewrite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: add deployment filter to flow run state trigger configuration

2 participants