You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(contracts): malformed image and response context no longer blocks message send - #43386
An image or response context record with explicit undefined in optional metadata makes JSON encoding reject the entire message with Expected JSON value. Image source, response subagents and their environmentId, nested snapshot metadata, and citation comments bypass the existing validation that should drop malformed records and preserve valid siblings.
Deterministic repro on origin/main (cc61cdb1e434ec4468468487abee5c422b535be4)
From packages/contracts, run node --input-type=module with this standard input:
Observed: all six malformed cases print Expected JSON value at ["records"][1]. Expected: each malformed case encodes { version: 1, records: [valid] }, dropping only ctx_2 and preserving ctx_1. The two valid controls must preserve both records.
Change
Use Schema.optionalKey for the three fields and validate embedded snapshot sources and assistant citations as JSON at the composer-context boundary, so explicit undefined fails record validation before the outer JSON codec runs. Extend the existing wire-encoding regression test with six malformed fixtures and valid snapshot/citation controls. The standalone attachment and citation schemas retain their existing semantics. This shared contract applies to server, web, desktop, and mobile messages across providers and local/remote connections; no UI, RPC shape, or translation changes are needed.
Scope
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification
The extended regression failed on base with SchemaError: Expected JSON value at ["records"][1].
The complete composerContext.test.ts passed three consecutive runs on the fix (8/8 tests each).
vp run check:changed exited 0.
Real Node codec before/after transcript: all six malformed cases throw on base and encode cleanly with ctx_1 preserved after the fix; valid snapshot-source and citation-comment controls preserve both records.
Not shown: live WebSocket send, persistence round trip, provider execution, web/desktop/mobile interaction.
Authored by GPT-6.1 Sol (Codex); reviewed by Gemini 4 Neon (Antigravity).
No actionable comments were generated in the recent review.
Walkthrough
Composer context schemas now constrain image sources and response citations to JSON-compatible values and reject explicit undefined in selected optional fields. Wire tests cover valid image and response records and malformed records with missing optional values.
Changes: Composer context validation
Layer / File(s)
Summary
Schema constraints and wire validation packages/contracts/src/composerContext.ts, packages/contracts/src/composerContext.test.ts
Image sources and response citations now require JSON-compatible values. Optional image and response fields use optional-key validation. Wire tests cover valid records and cases with malformed optional values.
This change stops malformed optional image or response context fields from blocking message send, and valid sibling records are preserved. No merge-blocking risk was identified in the reviewed schema and test changes.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: malformed image and response context records with explicit undefined no longer block message send. The changeset adds optionalKey and JSON validation to composerContex…
Description check
The description follows the template's Problem, Change, Scope, and Verification sections. The Problem section gives a reproduction and expected behavior. The Change section explains the schema fix and…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: malformed image and response context records with explicit undefined no longer block message send. The changeset adds optionalKey and JSON validation to composerContext.ts and extends its wire-encoding test, so the title matches. It is long at 82 characters, but it is clear and specific.
Full details: Description check
Explanation
The description follows the template's Problem, Change, Scope, and Verification sections. The Problem section gives a reproduction and expected behavior. The Change section explains the schema fix and why no UI or RPC change is needed. Scope states it is a small bug fix and explains why no issue is linked. Verification lists focused test results, a failing base run, and a transcript, and it states what was not checked. The template's agent-attribution line is present. The Scope section does not link an issue, which the template allows for small obvious fixes. The Verification transcript is an external gist, and the description embeds no screenshots, which is acceptable because this is not a UI change.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Reviewing files that changed from the base of the PR and between 12c1152 and 19042fb.
Files selected for processing: 2
packages/contracts/src/composerContext.test.ts
packages/contracts/src/composerContext.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:S10-29 changed lines (additions + deletions).vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
An image or response context record with explicit
undefinedin optional metadata makes JSON encoding reject the entire message withExpected JSON value. Imagesource, responsesubagentsand theirenvironmentId, nested snapshot metadata, and citation comments bypass the existing validation that should drop malformed records and preserve valid siblings.Deterministic repro on
origin/main(cc61cdb1e434ec4468468487abee5c422b535be4)From
packages/contracts, runnode --input-type=modulewith this standard input:Observed: all six malformed cases print
Expected JSON valueat["records"][1]. Expected: each malformed case encodes{ version: 1, records: [valid] }, dropping onlyctx_2and preservingctx_1. The two valid controls must preserve both records.Change
Use
Schema.optionalKeyfor the three fields and validate embedded snapshot sources and assistant citations as JSON at the composer-context boundary, so explicitundefinedfails record validation before the outer JSON codec runs. Extend the existing wire-encoding regression test with six malformed fixtures and valid snapshot/citation controls. The standalone attachment and citation schemas retain their existing semantics. This shared contract applies to server, web, desktop, and mobile messages across providers and local/remote connections; no UI, RPC shape, or translation changes are needed.Scope
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification
SchemaError: Expected JSON valueat["records"][1].composerContext.test.tspassed three consecutive runs on the fix (8/8 tests each).vp run check:changedexited 0.ctx_1preserved after the fix; valid snapshot-source and citation-comment controls preserve both records.Authored by GPT-6.1 Sol (Codex); reviewed by Gemini 4 Neon (Antigravity).