fix: defensive null checks for generated projection paths#136
Open
icebear0828 wants to merge 1 commit intogoogle-labs-code:mainfrom
Open
fix: defensive null checks for generated projection paths#136icebear0828 wants to merge 1 commit intogoogle-labs-code:mainfrom
icebear0828 wants to merge 1 commit intogoogle-labs-code:mainfrom
Conversation
…labs-code#135) project.generate() and screen.edit() crash with TypeError when the API returns an incomplete response (e.g. missing outputComponents or screens). The screen IS created server-side but the SDK fails to parse the response. Changes: - emitProjection() now uses optional chaining (?.) for simple projection chains - generateReturnExpression() adds a _projected guard with a descriptive StitchError for single-object returns with non-empty projection paths - Regenerated SDK classes with the new defensive patterns - Added 5 tests covering incomplete API responses for generate() and edit() Closes google-labs-code#135
This was referenced Mar 21, 2026
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.
Summary
project.generate()andscreen.edit()crash withTypeError: Cannot read properties of undefinedwhen the API returns an incomplete response (missingoutputComponentsorscreens)screen.variants()already handles this correctly with optional chaining —generate()andedit()did notChanges
emitProjection()now uses optional chaining (?.) for simple projection chainsgenerateReturnExpression()adds a_projectedguard with a descriptiveStitchErrorfor single-object returns with non-empty projection pathsrawreturn) skip the guard to avoid unnecessary codegenerate()andedit()Test plan
npx vitest run test/unit/sdk.test.ts— 20 tests passed (5 new)npx vitest run— 81 tests passed, 0 regressionsbun scripts/generate-sdk.ts— regeneration succeedsCloses #135