fix(google): guard null parts in planGoogleHistory user-turn scan - #259
Open
dex0shubham wants to merge 1 commit into
Open
fix(google): guard null parts in planGoogleHistory user-turn scan#259dex0shubham wants to merge 1 commit into
dex0shubham wants to merge 1 commit into
Conversation
planGoogleHistory scans contents for user turns with c.parts.some((p) => typeof p.text === 'string' && ...), dereferencing p.text without guarding p. A null element inside a contents turn's parts throws TypeError, which the proxy catches and returns as a 502 "pxpipe transform failed" - failing the whole Gemini request instead of forwarding it. Every other part-iterating function in the module guards null parts (googleHistoryUnit: `if (!part) continue`) and the module's contract is "malformed shape passes through unchanged" (tested). This one scan was the gap. Add the missing `p &&` guard and cover the contents null-part case in the existing malformed-passthrough test.
dex0shubham
force-pushed
the
fix/google-null-part-guard
branch
from
September 2, 2026 07:14
77cf40d to
887c36f
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
planGoogleHistory(src/core/google.ts) scanscontentsfor user turns:p.textis dereferenced without guardingp. Anullelement inside acontentsturn'spartsthrowsTypeError: Cannot read properties of null (reading 'text'). The proxy catches it and returns a 502 "pxpipe transform failed", so the whole Gemini request fails instead of being forwarded.This violates the module's own contract: every other part-iterating function guards null (
googleHistoryUnit:if (!part) { … continue }), and malformed request shapes are supposed to pass through unchanged. The existing test already pinssystemInstruction: { parts: [null] }as pass-through, but thecontentspath — the one that reaches this scan — was untested.Fix
Add the missing
p &&guard, matching the module's existing null-tolerance:Extended the existing malformed-passthrough test with
{ contents: [{ role: 'user', parts: [null] }] }. Verified it fails on the old code (TypeError) and passes with the fix.Full suite green (1204/1204);
typecheckclean.