Skip to content

Add warning/ignore for max event size#20526

Open
jakekaplan wants to merge 7 commits intomainfrom
dont-always-error-for-big-event
Open

Add warning/ignore for max event size#20526
jakekaplan wants to merge 7 commits intomainfrom
dont-always-error-for-big-event

Conversation

@jakekaplan
Copy link
Contributor

@jakekaplan jakekaplan commented Feb 2, 2026

Event size limits exist on both OSS + Cloud. Before #19531, oversize events were accepted then silently dropped server‑side, which can hide missing automations/state updates and is hard to debug. Raising EventTooLarge fails fast and makes the problem visible so users can adjust payloads.

That being said, this PR makes raising that error configurable so users can still continue to write their workflows as they have before. That should unblock users in the short‑term. However, longer‑term I believe we'll need to possibly investigate how handle oversized events (for example a task run event that has tens of thousands of task run dependencies).

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 2, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing dont-always-error-for-big-event (0e8fce4) with main (b39f34f)1

Summary

✅ 2 untouched benchmarks

Footnotes

  1. No successful run was found on main (4bb571f) during the generation of this report, so b39f34f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@jakekaplan jakekaplan marked this pull request as ready for review February 3, 2026 15:24
if event_obj.size_bytes > max_size:
raise EventTooLarge(event_obj.size_bytes, max_size)
if behavior == "error":
raise EventTooLarge(event_obj.size_bytes, max_size)
Copy link
Member

Choose a reason for hiding this comment

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

I think we should include a blurb about how to change this to a warning by updating the maximum_size_bytes_behavior setting.

Copy link
Contributor Author

@jakekaplan jakekaplan Feb 3, 2026

Choose a reason for hiding this comment

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

good call, added!

jakekaplan and others added 3 commits February 3, 2026 11:01
Co-authored-by: Alex Streed <desertaxle@users.noreply.github.com>
@jakekaplan jakekaplan requested a review from desertaxle February 3, 2026 16:11
Copy link
Member

@desertaxle desertaxle left a comment

Choose a reason for hiding this comment

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

Sorry, I missed some stuff on my first review. Feel free to punt on retrieving the settings via the API, and I can address that in a separate PR.

Comment on lines 79 to 83
validation_alias=AliasChoices(
AliasPath("maximum_size_bytes_behavior"),
"prefect_server_events_maximum_size_bytes_behavior",
"prefect_events_maximum_size_bytes_behavior",
),
Copy link
Member

Choose a reason for hiding this comment

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

Sorry I missed this in the first review, but you don't need these aliases for a new setting. Those are used for backward compatibility.

Suggested change
validation_alias=AliasChoices(
AliasPath("maximum_size_bytes_behavior"),
"prefect_server_events_maximum_size_bytes_behavior",
"prefect_events_maximum_size_bytes_behavior",
),

Comment on lines +100 to +102
events_settings = get_current_settings().server.events
max_size = events_settings.maximum_size_bytes
behavior = events_settings.maximum_size_bytes_behavior
Copy link
Member

Choose a reason for hiding this comment

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

I know this was already like this, but I'd rather access server settings directly in the client since those are only supposed to control server behavior. Instead, we should read the server settings via the /admin/settings endpoint.

),
)

maximum_size_bytes_behavior: Literal["error", "warn", "ignore"] = Field(
Copy link
Member

Choose a reason for hiding this comment

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

I just realized this is a server setting, but it should probably go in a new model in prefect/src/prefect/settings/models/events.py instead.

@jakekaplan
Copy link
Contributor Author

Sorry, I missed some stuff on my first review. Feel free to punt on retrieving the settings via the API, and I can address that in a separate PR.

Oh no worries! Let me take a look at this again, I didn't realize this was a server setting originally

@github-actions
Copy link
Contributor

This pull request is stale because it has been open 14 days with no activity. To keep this pull request open remove stale label or comment.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants