Skip to content

fix: cap tag related resources to event maximum - #22694

Open
vedjaw wants to merge 3 commits into
PrefectHQ:mainfrom
vedjaw:fix/19064-cap-event-tag-related-resources
Open

fix: cap tag related resources to event maximum#22694
vedjaw wants to merge 3 commits into
PrefectHQ:mainfrom
vedjaw:fix/19064-cap-event-tag-related-resources

Conversation

@vedjaw

@vedjaw vedjaw commented Aug 1, 2026

Copy link
Copy Markdown

Summary

Fixes #19064

Deployments can store more than 100 tags, but flow-run state-change events
convert each tag into a related resource and enforce
server.events.maximum_related_resources (default 100). That caused
runtime validation failures for otherwise-valid deployments.

Fix

  • Truncate tag-related resources in _resource_data_as_related_resources,
    reserving one slot for provenance
  • Apply the same cap in client-side tags_as_related_resources
  • Tags remain fully stored on deployments/flow runs; only event embedding
    is capped

Test plan

  • Added regression test creating a deployment/flow run with 101 tags

Made with Cursor

Deployments may carry more than 100 tags, but events reject more than
the configured maximum related resources. Truncate tag-related resources
when building events so flow-run creation no longer fails.

Fixes PrefectHQ#19064

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the bug Something isn't working label Aug 1, 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: c6acb6bfdc

ℹ️ 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 thread src/prefect/events/related.py Outdated
@codspeed-hq

codspeed-hq Bot commented Aug 1, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 8 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing vedjaw:fix/19064-cap-event-tag-related-resources (1963382) with main (b535a27)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

vedjaw added 2 commits August 8, 2026 17:52
`tags_as_related_resources()` is public, and reserving a hard-coded 10 slots meant
any caller with fewer than 10 non-tag related resources silently lost tags. With
the default `maximum_related_resources` of 100, a caller with no other resources
got 90 tags instead of 100, so automations or filters matching a dropped tag
stopped seeing those events.

Take the count from the caller instead. `reserved` defaults to 0, so the helper
now yields every tag that fits, and the four call sites pass `len(related)` --
the number of slots they have actually composed.

The server-side cap in `_resource_data_as_related_resources` already worked this
way, computing from `len(related)`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deployment and events have different tag limits

1 participant