project.generate() intermittently throws Cannot read properties of undefined (reading 'screens') when the API returns an incomplete response. The screen IS successfully created on Stitch (visible in the dashboard at stitch.withgoogle.com/projects), but the SDK fails to parse the response.
Root cause (project.js line 29):
return new Screen(this.client, {
...raw.outputComponents[0].design.screens[0], // no null checks
projectId: this.projectId
});
screen.variants() already handles this correctly with optional chaining:
((raw.outputComponents || []).flatMap((a) => a?.design?.screens || []) || [])
generate() and edit() should use the same defensive pattern.
Environment: @google/stitch-sdk v0.0.3, model GEMINI_3_FLASH
project.generate() intermittently throws Cannot read properties of undefined (reading 'screens') when the API returns an incomplete response. The screen IS successfully created on Stitch (visible in the dashboard at stitch.withgoogle.com/projects), but the SDK fails to parse the response.
Root cause (project.js line 29):
return new Screen(this.client, {
...raw.outputComponents[0].design.screens[0], // no null checks
projectId: this.projectId
});
screen.variants() already handles this correctly with optional chaining:
((raw.outputComponents || []).flatMap((a) => a?.design?.screens || []) || [])
generate() and edit() should use the same defensive pattern.
Environment: @google/stitch-sdk v0.0.3, model GEMINI_3_FLASH