Skip to content

Fit a webhook payload whose top-level fields alone exceed the cap, instead of looping forever - #707

Merged
davidmckayv merged 3 commits into
CopilotKit:mainfrom
Chebaleomkar:fix/trigger-payload-cap
Oct 2, 2026
Merged

davidmckayv merged 3 commits into
CopilotKit:mainfrom
Chebaleomkar:fix/trigger-payload-cap

Conversation

@Chebaleomkar

Copy link
Copy Markdown
Contributor

What this changes

fitPayload (server/src/responsibilities/triggers.ts) keeps every top-level scalar of an oversized trigger payload, each cut to 1000 characters, then trims excerpt by 1024 characters per pass until the whole fits in 32 KiB. When the scalars alone exceed 32 KiB (for example a flat webhook body with forty 1000-character fields, about 40 KB and well under the 256 KiB body limit), excerpt reaches "", "".slice(0, -1024) stays "", and the while never ends. It runs synchronously, so the server stops answering every request.

The kept scalars now get at most half the cap. Fields past that are left out of the top level and remain in the excerpt.

Where it runs

Server: generic and provider webhook triggers (trigger-routes.ts calls fitPayload before recording the event).

Boundary and audit

No change to signature checks or to what is recorded, apart from which scalars are hoisted.

Changelog

Entry under Unreleased.

Proof

New case in server/tests/responsibility-triggers.test.ts. On main it never returns (killed by timeout 60, exit 124). With the fix the file passes 28/28. Biome format and lint are clean.

fitPayload kept every top-level scalar (up to 1000 chars each) and then
trimmed the excerpt until the whole fit in 32 KiB. When the scalars
alone exceeded that, the excerpt reached "" and the loop never ended,
blocking the event loop. Give the kept scalars half the cap.
@davidmckayv
davidmckayv merged commit 8c4b448 into CopilotKit:main Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants