Skip to content

Bound rejected extension payloads in fallback diagnostics - #7431

Merged
ymichael merged 1 commit into
get-bb:mainfrom
lanjak:fix-6025-bound-rejected-extension-payloads
Nov 16, 2026
Merged

ymichael merged 1 commit into
get-bb:mainfrom
lanjak:fix-6025-bound-rejected-extension-payloads

Conversation

@lanjak

@lanjak lanjak commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

validateSite in apps/server/src/internal/extension-payloads.ts rejects provider extension payloads over EXTENSION_PAYLOAD_MAX_BYTES (64 KiB). Each rejection becomes a provider/unhandled diagnostic through toUnhandledEvent, which copied site.payload into rawEvent.params.payload unchanged. The size limit stopped the extension update but not the stored copy, so repeated rejected snapshots kept large hidden history (#6025). The ownership and undeclared-kind checks run before the size check, so oversized payloads they reject were stored in full too. Validator reasons had no length limit.

What changed

  • extension-payloads.ts: toUnhandledEvent measures the payload in UTF-8 bytes with the same Buffer.byteLength(JSON.stringify(...)) that the size check uses. A payload over the limit is replaced by payloadOmitted: true and payloadBytes. A payload at or under the limit is kept, as before. The reason is cut to 4,096 characters with the existing sliceUtf16Head from @bb/text-utils and a ... [truncated] marker. Kind, method, scope, providerThreadId and parentToolCallId are unchanged.
  • internal-extension-payloads.test.ts: regressions for the issue's item and state cases, a table of payloads at the limit and one byte over it on the ownership, undeclared-kind and core bb/provider-commands paths, and a test for a long validator reason.

The two new fields are inside rawEvent.params of a diagnostic event. No code reads params.payload from these events. No wire, schema or protocol version change. Rows stored before this change are not rewritten.

How you verified

  • Before the fix (new tests, old extension-payloads.ts): 4 of 13 fail, for example expected { kind: 'provider-nobody/goal', …(2) } to not have property "payload" and expected false to be true for the reason length.
  • After the fix: internal-extension-payloads.test.ts passes 13 of 13. pnpm exec turbo run lint lint:type-aware typecheck --filter=@bb/server passes, 7 of 7 tasks, 0 warnings. oxfmt --check passes on the changed files.
  • pnpm exec turbo run test --filter=@bb/server: 4,044 passed. The 2 failures are timeouts in test/app/install-machine-script.test.ts, which also fails on unchanged main under a full run and passes alone.

Fixes #6025

AGENT GENERATED

When the server rejected an extension item or state event, it replaced it
with a provider/unhandled diagnostic that copied the full original payload.
A payload rejected for exceeding the 64 KiB limit, or rejected for
ownership or a missing schema before the size check ran, was still stored
in full, so repeated rejected snapshots filled the event history.

The diagnostic now keeps the payload only when it fits the 64 KiB limit.
A larger payload is replaced by payloadOmitted: true and its UTF-8
payloadBytes, on every rejection path. The rejection reason is capped at
4096 characters with a truncation marker, so a large validator message
cannot defeat the bound. Kind, provider, method, scope, and parent tool
call provenance are unchanged.

Fixes get-bb#6025
@ymichael
ymichael merged commit b35f0e1 into get-bb:main Nov 16, 2026
28 checks passed
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.

Bound rejected extension payloads in fallback diagnostics

2 participants