Skip to content

project.generate() crashes on incomplete API response — missing defensive null checks #135

@saintwknd

Description

@saintwknd

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    fleetFleet-managed issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions