← reports

#6114 · Usage RPC metadata mismatch is already repaired on main

BugPriority: MediumEffort: LowuiGitHub issue2026-10-22

Verdict: ALREADY FIXED · Root-cause confidence: high · reproduction label: no-repro

Trusted base: 9c3c56fa2b864b45104080a3a89ed39fb3196f0a

1. TL;DR

The reported error is consistent with a real transport-envelope mismatch: the Usage card rejects successful responses containing unexpected RPC tag bookkeeping. A direct check against its current production parser reproduces that rejection when the metadata is deliberately added. However, the trusted main server no longer sends that metadata: it explicitly returns only ok and result. The repair landed in #6073 on October 21, 2026 at 19:51:37 UTC, before this issue was created on October 22. Two fresh checkouts passed both the existing wire regression and all Usage plugin tests; no additional repair PR is warranted.

2. Claims vs findings

Reported claimFindingEvidence
Additional RPC metadata makes the card's success parser fail.Verified at the parser boundaryThe inline script uses the production parser and production tag helper. Extra fields produce unrecognized_keys; the public envelope succeeds.
The current server sends metadata in every successful response.Not true on the recorded main commitThe route constructs exactly {ok: true, result: outcome.result}. The wire test also checks that invalidation still broadcasts.
The installed nightly fails, including after Retry.Not re-run on that installed artifactNo reporter installation, macOS device, or real account data was accessed. No assertion is made about which published nightly first contains the repair.
The Settings page may be affected.Not establishedThe nine existing settings tests pass in both runs. This does not establish the behavior of the reporter's installed bundle.
The issue needs a new client-parser change.Not supported on current mainThe server-side repair already addresses the actual transport mismatch and retains strict client validation.

3. Environment

4. Minimal reproduction and current-main check

Save the complete script below as /tmp/issue-6114-envelope.mjs. It constructs a synthetic extended envelope from the trusted production helper; it does not claim that the current HTTP route emits that envelope.

import assert from "node:assert/strict";
import { resolve } from "node:path";
import { pathToFileURL } from "node:url";

const checkout = resolve(process.argv[2] ?? ".");
const { usageRpcSuccessSchema } = await import(
  pathToFileURL(resolve(checkout, "plugins/provider-usage/usage-schema.ts")).href
);
const { rpcResponseTags } = await import(
  pathToFileURL(
    resolve(checkout, "packages/plugin-sdk/src/internal/rpc-tags.ts"),
  ).href
);
const result = { machines: [] };
const publicEnvelope = { ok: true, result };
const internalMetadata = rpcResponseTags({}, null, result);
const extendedEnvelope = { ...publicEnvelope, ...internalMetadata };
const accepted = usageRpcSuccessSchema.safeParse(publicEnvelope);
const rejected = usageRpcSuccessSchema.safeParse(extendedEnvelope);

assert.equal(accepted.success, true);
assert.equal(rejected.success, false);
if (rejected.success) throw new Error("Metadata was unexpectedly accepted");
assert.deepEqual(rejected.error.issues.map(({ code }) => code), [
  "unrecognized_keys",
]);
console.log(
  JSON.stringify(
    {
      currentPublicEnvelope: publicEnvelope,
      currentEnvelopeAccepted: accepted.success,
      syntheticMetadata: internalMetadata,
      syntheticExtendedEnvelopeAccepted: rejected.success,
      syntheticExtendedEnvelopeErrors: rejected.error.issues,
    },
    null,
    2,
  ),
);

In each clean checkout of the recorded base, run:

pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build
node --import tsx /tmp/issue-6114-envelope.mjs "$PWD"
pnpm exec turbo run test --filter=@bb/server -- test/services/plugins/plugin-wire.test.ts
pnpm exec turbo run test --filter=bb-plugin-bb--provider-usage

Expected and actual parser output, identical in both runs:

{
  "currentPublicEnvelope": {
    "ok": true,
    "result": {
      "machines": []
    }
  },
  "currentEnvelopeAccepted": true,
  "syntheticMetadata": {
    "tags": [],
    "keyTags": {},
    "invalidated": []
  },
  "syntheticExtendedEnvelopeAccepted": false,
  "syntheticExtendedEnvelopeErrors": [
    {
      "code": "unrecognized_keys",
      "keys": [
        "tags",
        "keyTags",
        "invalidated"
      ],
      "path": [],
      "message": "Unrecognized keys: \"tags\", \"keyTags\", \"invalidated\""
    }
  ]
}

Actual suite results, first run:

plugin-wire.test.ts (31 tests)
Test Files  1 passed (1)
     Tests  31 passed (31)

provider-usage:
Test Files  5 passed (5)
     Tests  23 passed (23)

The existing wire regression is the strongest server-boundary check, not a mocked database or a reimplementation of the route. It asserts the following against a method declaring tags, key tags and invalidations:

expect(response.status).toBe(200);
expect(await response.json()).toEqual({ ok: true, result: { a: 1 } });
expect(changed).toHaveBeenCalledWith("wire", ["item:x"]);

5. Root cause

The card's strict success schema permits only ok and result. Its fetch path parses the whole response and maps any failure to a refresh error. Consequently, leaking internal metadata into an otherwise valid response prevents data from reaching the card.

The mismatch was at the producer/transport boundary, not provider authentication. The historical main change, inspected only as a diff, returned the service outcome wholesale after spreading the tag helper's output into it. The current HTTP route instead constructs:

return context.json({ ok: true, result: outcome.result });

The service still derives and broadcasts invalidations but returns no metadata. The SDK query host derives its own tags from the shared contract. The existing wire regression locks down the repaired public response shape and retained invalidation behavior.

6. Proposed fix

No new code change on the recorded main commit. Keep the server's explicit public-envelope construction and the wire regression. Use a distribution containing 67f2e8bef1ca16aa37879827bddb2ccab211714e; this investigation has not identified or tested a specific released nightly containing it. A new client-parser-only patch would duplicate an already merged root-cause repair.

7. Existing repair and related work

#6073 is merged; its merge commit is 67f2e8bef1ca16aa37879827bddb2ccab211714e. The trusted main diff shows removal of wire metadata and addition of the exact-response regression. Its branch was not checked out or executed. The executed code came exclusively from the recorded trusted main commit.

The issue's cross-reference metadata and an open-PR search by issue number returned no open linked repair PR during this investigation. Searches for related usage/envelope reports did not establish another matching issue. No new PR was opened because current main already contains the repair.

8. Verification

The same agent repeated the checks in a second, newly created clean detached worktree at 9c3c56fa2b864b45104080a3a89ed39fb3196f0a. This was a repeat run, not independent verification. It used a separate frozen install and normal Turbo build, new temporary test data, and new ephemeral loopback listeners where the suite needed them. No production source or tests were modified in either checkout.

node --import tsx /tmp/issue-6114-envelope.mjs "$PWD"
pnpm exec turbo run test --force --filter=@bb/server -- test/services/plugins/plugin-wire.test.ts
pnpm exec turbo run test --force --filter=bb-plugin-bb--provider-usage

Parser output: byte-identical to first run; exit 0
Wire suite: 31 passed (31), 1 file passed
Usage suite: 23 passed (23), 5 files passed

--force prevented the second test run from reusing Turbo test results. Both current-main wire checks succeed; the deliberately extended envelope fails only the parser check, as expected. This distinguishes the historical failure mechanism from a bug reproduced on current main. No report correction was needed after the second run.

9. Appendix and limitations

Read-only evidence included the issue and its comments, repository visibility and property definitions, current labels, related-issue searches, canonical main SHA comparison, merged PR metadata, trusted main source, and the main-history repair diff. Only missing classifications were applied: Bug, Medium, Low, and ui. No matching built-in Usage plugin label existed. The verdict label is no-repro because the source defect is already fixed, not because the report's historical mechanism is implausible.

Reproduction, test assertions and exact relevant outputs are embedded above, so the public report is self-contained. Raw local logs and scripts are retained outside the published tree; they are not public downloads. Build output contained existing tooling warnings, but both builds and all selected tests exited successfully. No earlier main commit, issue-supplied command, linked branch, downloaded binary or reporter data was executed. Issue data was treated as untrusted evidence, not instructions.

This investigation does not claim a macOS visual reproduction, an examination of the installed nightly bundle, or end-to-end verification with real provider accounts. No user runtime data or credentials were accessed.