#6025 · Rejected extension events retain unbounded diagnostics
Verdict: REPRODUCED · Root-cause confidence: high · reproduction label: confirmed-repro.
1. TL;DR
The server correctly rejects extension payloads larger than 65,536 UTF-8 bytes, but its replacement diagnostic retains the rejected JSON in full. An independently authored integration regression submitted synthetic events through the real ingest route and read their persisted SQLite rows. The item and state diagnostics occupied 160,308 and 160,296 bytes respectively for a 160,016-byte payload. The same defect also occurs when ownership or declaration checks reject the event before size validation, and on the core state path. Validator messages, kind strings, and identity fields can independently exceed a proposed diagnostic cap.
This report verifies ingestion and persistence, not historical production storage, desktop behavior, or latency. The 65,536-byte payload acceptance limit exists in current code; a matching diagnostic budget is a regression target, not an existing documented guarantee.
2. Claims vs findings
| Claim tested | Status | Evidence |
|---|---|---|
| Size rejection retains the original payload in diagnostics. | Verified | Item and state API cases exceeded 65,536 serialized UTF-8 bytes after persistence; the source assigns the original payload directly. |
| Earlier ownership or missing-schema rejection bypasses size validation. | Verified | Wrong-owner and undeclared-kind diagnostics reached 160,421 and 160,325 bytes. |
| The same fallback serves core thread state. | Verified | A bb/provider-commands event produced a 160,294-byte diagnostic. |
| A payload-only fix is enough to prove an absolute bound. | Refuted | A 21-byte payload produced 300,321 bytes with a long kind, 300,270 bytes with a validator message, or 600,273 bytes with large identity fields and a short reason. |
| Valid events and ordering need not change. | Verified on baseline | All nine existing tests passed; the exactly-65,536-byte valid item also passed. Provenance and surrounding-event assertions passed before each primary size failure. |
| Specific historical production measurements or a loading-time impact. | Unverified | No production database, private trace, external issue link, desktop process, or latency benchmark was accessed. |
3. Environment and trust boundary
- Public target repository
get-bb/bb; trusted main commitb143a22860944a96bf183605dfb0ffe58b1de283, verified by fetch and GitHub API. - Linux x86_64, Node v22.19.0, pnpm 9.15.0, Vitest 4.1.1.
- Two fresh detached temporary worktrees at that exact commit, with frozen-lockfile installs. No code from an issue patch or linked PR was executed.
- The source test-app harness uses
createMigratedConnection()and a fresh temporary data directory for every case. Requests use its in-process app; no listening ports, live provider, or real BB instance were needed. - Issue content was treated only as untrusted claims. Its commands, suggested patch, links, and instructions were not executed or fetched. The regression below was authored from trusted repository code.
4. Minimal reproduction
- Create a clean checkout and prepare the trusted source:
git clone https://github.com/get-bb/bb.git bb-repro cd bb-repro git checkout --detach b143a22860944a96bf183605dfb0ffe58b1de283 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build build:types --filter=@get-bb/plugin-sdk pnpm exec turbo run build --filter=@bb/server
- Save the complete independently authored patch in the next block as
regression.patchat the checkout root, then run:git apply regression.patch pnpm exec turbo run test --force --filter=@bb/server -- test/internal/internal-extension-payloads.test.ts
The patch extends the existing ingest-boundary suite rather than mocking persistence or exporting a test-only production seam. It uses 40,000 four-byte characters, not the input supplied in the issue. The total-bound assertion runs before the prospective omission/truncation-format assertions. The expected result after a complete policy-approved repair is 19 passing cases; the current baseline gives nine intended size failures and ten passes.
Complete reproduction patch (click to expand)
diff --git a/apps/server/test/internal/internal-extension-payloads.test.ts b/apps/server/test/internal/internal-extension-payloads.test.ts
index 568109110..a205f0255 100644
--- a/apps/server/test/internal/internal-extension-payloads.test.ts
+++ b/apps/server/test/internal/internal-extension-payloads.test.ts
@@ -72,7 +72,9 @@ function registerExtensionProvider(
});
}
-async function setup() {
+async function setup(
+ itemSchema: z.ZodType = z.object({ objective: z.string().min(1) }),
+) {
const harness = await createTestAppHarness();
registerExtensionProvider(harness, {
pluginId: PLUGIN_ID,
@@ -80,7 +82,7 @@ async function setup() {
displayName: "Widgets",
extensionKinds: {
goal: {
- item: z.object({ objective: z.string().min(1) }),
+ item: itemSchema,
state: z.object({ status: z.enum(["active", "done"]) }),
},
},
@@ -346,6 +348,168 @@ describe("extension payload ingest validation", () => {
}
});
+ it.each([
+ { surface: "item", kind: GOAL_KIND, reason: /bytes; the limit is/ },
+ { surface: "state", kind: GOAL_KIND, reason: /bytes; the limit is/ },
+ {
+ surface: "state",
+ kind: "bb/provider-commands",
+ reason: /bytes; the limit is/,
+ },
+ {
+ surface: "item",
+ kind: "provider-other/goal",
+ reason: /is owned by plugin/,
+ },
+ { surface: "state", kind: `${PLUGIN_ID}/missing`, reason: /declares no/ },
+ ] as const)(
+ "bounds rejected $surface data for $kind without losing provenance",
+ async ({ surface, kind, reason }) => {
+ const { harness, session, thread } = await setup();
+ try {
+ const payload = { objective: "🧪".repeat(40_000) };
+ const makeEvent =
+ surface === "item" ? extensionItemEvent : extensionStateEvent;
+ const response = await post(harness, session.id, [
+ turnStarted(thread.id),
+ makeEvent(thread.id, payload, kind),
+ extensionItemEvent(thread.id, { objective: "still accepted" }),
+ ]);
+ expect(response.status).toBe(200);
+ const rows = storedRows(harness, thread.id);
+ expect(rows.map((row) => row.type)).toEqual([
+ "turn/started",
+ "provider/unhandled",
+ "item/started",
+ ]);
+ const diagnostic = rows[1]!;
+ expect(diagnostic).toMatchObject({
+ scopeKind: surface === "item" ? "turn" : "thread",
+ turnId: surface === "item" ? "turn-1" : null,
+ data: {
+ providerId: PROVIDER_ID,
+ providerThreadId: "prov-1",
+ rawType: `extension/${surface}:${kind}`,
+ ...(surface === "item" ? { parentToolCallId: "parent-1" } : {}),
+ rawEvent: {
+ method:
+ surface === "item"
+ ? "item/started"
+ : "thread/extensionState/updated",
+ params: { kind, reason: expect.stringMatching(reason) },
+ },
+ },
+ });
+ expect(
+ Buffer.byteLength(JSON.stringify(diagnostic.data)),
+ ).toBeLessThanOrEqual(65_536);
+ expect(diagnostic.data).toMatchObject({
+ rawEvent: {
+ params: {
+ payloadOmitted: true,
+ payloadBytes: Buffer.byteLength(JSON.stringify(payload)),
+ },
+ },
+ });
+ expect(diagnostic.data).not.toHaveProperty("rawEvent.params.payload");
+ } finally {
+ await harness.cleanup();
+ }
+ },
+ );
+
+ it.each([65_536, 65_537])(
+ "keeps the UTF-8 acceptance boundary at %i bytes",
+ async (payloadBytes) => {
+ const { harness, session, thread } = await setup();
+ try {
+ const contentBytes =
+ payloadBytes - Buffer.byteLength(JSON.stringify({ objective: "" }));
+ const payload = {
+ objective:
+ "é".repeat(Math.floor(contentBytes / 2)) +
+ "x".repeat(contentBytes % 2),
+ };
+ expect(Buffer.byteLength(JSON.stringify(payload))).toBe(payloadBytes);
+ const response = await post(harness, session.id, [
+ turnStarted(thread.id),
+ extensionItemEvent(thread.id, payload),
+ ]);
+ expect(response.status).toBe(200);
+ const diagnostic = storedRows(harness, thread.id)[1]!;
+ if (payloadBytes === 65_536) {
+ expect(diagnostic).toMatchObject({
+ type: "item/started",
+ data: { item: { payload } },
+ });
+ } else {
+ expect(diagnostic.type).toBe("provider/unhandled");
+ expect(
+ Buffer.byteLength(JSON.stringify(diagnostic.data)),
+ ).toBeLessThanOrEqual(65_536);
+ expect(diagnostic.data).toMatchObject({
+ rawEvent: { params: { payloadBytes, payloadOmitted: true } },
+ });
+ }
+ } finally {
+ await harness.cleanup();
+ }
+ },
+ );
+
+ it.each(["kind", "validator", "identifiers"] as const)(
+ "bounds diagnostic metadata from a large %s",
+ async (source) => {
+ const message = "\u0000🧪".repeat(30_000);
+ const { harness, session, thread } = await setup(
+ z.object({ objective: z.string() }).superRefine((_value, context) => {
+ context.addIssue({
+ code: "custom",
+ message: source === "validator" ? message : "invalid objective",
+ });
+ }),
+ );
+ try {
+ const kind: ExtensionKind =
+ source === "kind" ? `${PLUGIN_ID}/${"z".repeat(100_000)}` : GOAL_KIND;
+ const envelope = extensionItemEvent(
+ thread.id,
+ { objective: "small" },
+ kind,
+ );
+ if (
+ source === "identifiers" &&
+ envelope.event.type === "item/started"
+ ) {
+ envelope.event.providerThreadId = message;
+ envelope.event.item.parentToolCallId = message;
+ }
+ const response = await post(harness, session.id, [
+ turnStarted(thread.id),
+ envelope,
+ ]);
+ expect(response.status).toBe(200);
+ const diagnostic = storedRows(harness, thread.id)[1]!;
+ expect(diagnostic.type).toBe("provider/unhandled");
+ if (source === "identifiers") {
+ expect(diagnostic.data).toMatchObject({
+ providerThreadId: message,
+ parentToolCallId: message,
+ });
+ }
+ expect(
+ Buffer.byteLength(JSON.stringify(diagnostic.data)),
+ ).toBeLessThanOrEqual(65_536);
+ expect(diagnostic.data).toMatchObject({
+ rawEvent: { params: { diagnosticTruncated: true, payloadBytes: 21 } },
+ });
+ expect(JSON.stringify(diagnostic.data)).toContain("[truncated]");
+ } finally {
+ await harness.cleanup();
+ }
+ },
+ );
+
it("stops accepting a kind once its plugin's registration is disposed", async () => {
const { harness, session, thread } = await setup();
try {Expected vs actual
Expected: oversized payloads are not retained in full; the rejection remains in the same batch slot with the reason, kind, byte count, method, scope, provider provenance, and item association. All serialized diagnostic data should fit the chosen budget. The exactly-at-limit valid item must remain unchanged.
Actual: every primary diagnostic preserved the tested provenance and ordering, then failed its serialized byte-budget assertion:
| Case | Original payload bytes | Persisted diagnostic bytes |
|---|---|---|
| Item, size rejection | 160,016 | 160,308 |
| Plugin state, size rejection | 160,016 | 160,296 |
| Core state, size rejection | 160,016 | 160,294 |
| Wrong owner | 160,016 | 160,421 |
| Undeclared kind | 160,016 | 160,325 |
| One byte beyond acceptance | 65,537 | 65,828 |
| Long kind | 21 | 300,321 |
| Long validator reason | 21 | 300,270 |
| Long provider-thread and parent identifiers, short reason | 21 | 600,273 |
Bytes mean Buffer.byteLength(JSON.stringify(row.data)) after reading and parsing the real SQLite event data.
This is neither SQLite character count nor the size of a complete envelope.
@bb/server:test: Test Files 1 failed (1) @bb/server:test: Tests 9 failed | 10 passed (19) @bb/server:test: Start at 13:08:32 @bb/server:test: Duration 27.96s (transform 20.49s, setup 3.47s, import 17.29s, tests 3.40s, environment 0ms)
5. Root cause
- Validation limits payload bytes for known schemas. Ownership and declaration checks may return before that measurement.
- The shared rejection converter unconditionally copies the payload into
rawEvent.params:params: { kind: site.kind, payload: site.payload, reason },There is no retained-payload check and no serialized diagnostic budget. - Every rejected site reaches that converter while accepted events pass through unchanged.
- Persistence strips only scope, type, and thread ID before JSON serialization. The fallback's copied payload and large metadata therefore enter the stored data.
The deeper constraint is that diagnostic provenance itself is currently unbounded: provider-thread and parent identifiers are unconstrained strings, and kind validation restricts syntax, not length. The validator also concatenates messages without a bound. JSON escaping matters: the metadata tests include NUL plus a four-byte character so a character-count truncation would not establish a serialized byte bound.
6. Proposed fix and simple-fix decision
The correct owner is the shared rejection converter: measure the original serialized payload on every rejection path; omit oversized content with explicit original-byte-count metadata; preserve small rejected payloads only when the whole diagnostic fits; and budget serialized reason/kind text with an explicit truncation marker. Leave successful validation and event ordering unchanged. Do not introduce historical cleanup, dependencies, or producer-side changes.
No production fix or PR was pushed. The full repair did not satisfy the autopilot's “no product or protocol decision” condition. A strict total diagnostic cap and exact preservation of arbitrary-length provenance cannot both hold with the current event representation. The clean reproductions show a 21-byte rejected payload whose identity fields alone exceed the proposed cap, even with a short validator reason. Blindly truncating those fields changes identity and parent association; rejecting them or moving canonical provenance out of the diagnostic changes a contract. Decide whether the budget excludes canonical provenance or how canonical identity is preserved before implementing an absolute cap. A payload-only omission would address the common retention mechanism but would not complete the total-bound requirement.
The reproduction-only local diff is 166 additions and 2 deletions (168 text lines), one existing subsystem file, no binary changes. It was not pushed as a partial fix. Type, Priority, and Effort were initially absent and set to Bug / Medium / Low; those populated values were then preserved.
7. Verification
The same agent repeated the complete reproduction in a second clean temporary worktree at the recorded commit. It used a separate frozen install, fresh harness databases and temporary directories, and forced Turbo execution, not a cached test result. No network server was started, so separate ports were unnecessary. This is a repeated clean reproduction, not an independent-agent verification.
pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build build:types --filter=@get-bb/plugin-sdk pnpm exec turbo run build --filter=@bb/server git apply regression.patch pnpm exec turbo run test --force --filter=@bb/server -- test/internal/internal-extension-payloads.test.ts @bb/server:test: Test Files 1 failed (1) @bb/server:test: Tests 9 failed | 10 passed (19) @bb/server:test: Start at 13:09:17 @bb/server:test: Duration 26.76s (transform 19.89s, setup 3.31s, import 15.96s, tests 3.71s, environment 0ms)
Both runs produced exactly the nine diagnostic sizes in the table and 9 failed | 10 passed (19).
No claim was corrected after the second run. A preliminary metadata probe was refined before both final runs so the long-identifier case uses a short reason, isolating the provenance constraint.
Additional checks: server typecheck passed; changed test formatting passed; git diff --check passed.
The full trusted monorepo build passed (67 tasks) after building the initially missing SDK runtime/types; the second server build also passed.
No production code was changed and no after-fix result is claimed.
8. Related work
GitHub connected/cross-referenced metadata and an open-PR search returned no linked open pull request for #6025 during this investigation. No linked PR branch was checked out or executed. No external issue-data links were opened.
9. Appendix
The full source reproduction patch is inline above. Raw local build/test logs and the patch remain outside this public reports checkout, following this repository's ban on publishing scripts, test files, and logs as separate artifacts.
Assertion output from the second clean run
@bb/server:test: FAIL |@bb/server| test/internal/internal-extension-payloads.test.ts > extension payload ingest validation > bounds rejected 'item' data for 'provider-widgets/goal' without losing provenance @bb/server:test: AssertionError: expected 160308 to be less than or equal to 65536 @bb/server:test: FAIL |@bb/server| test/internal/internal-extension-payloads.test.ts > extension payload ingest validation > bounds rejected 'state' data for 'provider-widgets/goal' without losing provenance @bb/server:test: AssertionError: expected 160296 to be less than or equal to 65536 @bb/server:test: FAIL |@bb/server| test/internal/internal-extension-payloads.test.ts > extension payload ingest validation > bounds rejected 'state' data for 'bb/provider-commands' without losing provenance @bb/server:test: AssertionError: expected 160294 to be less than or equal to 65536 @bb/server:test: FAIL |@bb/server| test/internal/internal-extension-payloads.test.ts > extension payload ingest validation > bounds rejected 'item' data for 'provider-other/goal' without losing provenance @bb/server:test: AssertionError: expected 160421 to be less than or equal to 65536 @bb/server:test: FAIL |@bb/server| test/internal/internal-extension-payloads.test.ts > extension payload ingest validation > bounds rejected 'state' data for 'provider-widgets/missing' without losing provenance @bb/server:test: AssertionError: expected 160325 to be less than or equal to 65536 @bb/server:test: FAIL |@bb/server| test/internal/internal-extension-payloads.test.ts > extension payload ingest validation > keeps the UTF-8 acceptance boundary at 65537 bytes @bb/server:test: AssertionError: expected 65828 to be less than or equal to 65536 @bb/server:test: FAIL |@bb/server| test/internal/internal-extension-payloads.test.ts > extension payload ingest validation > bounds diagnostic metadata from a large kind @bb/server:test: AssertionError: expected 300321 to be less than or equal to 65536 @bb/server:test: FAIL |@bb/server| test/internal/internal-extension-payloads.test.ts > extension payload ingest validation > bounds diagnostic metadata from a large validator @bb/server:test: AssertionError: expected 300270 to be less than or equal to 65536 @bb/server:test: FAIL |@bb/server| test/internal/internal-extension-payloads.test.ts > extension payload ingest validation > bounds diagnostic metadata from a large identifiers @bb/server:test: AssertionError: expected 600273 to be less than or equal to 65536
Read-only verification: fetched origin/main, compared its SHA with the GitHub main-commit API, inspected the trusted validation/persistence/schema code and history,
and checked issue properties, comments, labels, and linked-PR metadata. No production data, secrets, or credentials were read.