Skip to content

bug: Win11 generate can fail with raw 'Unexpected end of JSON input' #128

@Sun-sunshine06

Description

@Sun-sunshine06

Summary

On Windows 11, generation can fail with a raw main-process IPC error:

Error invoking remote method 'codesign:v1:generate': CodesignError: Unexpected end of JSON input

The error is surfaced directly to the user instead of being translated into an actionable message or recovered gracefully.

Environment

  • OS: Windows 11
  • App: open-codesign desktop
  • Provider/model: unknown from screenshot
  • Flow: normal generate via codesign:v1:generate

Repro

  1. Open open-codesign on Windows 11.
  2. Start a normal generation.
  3. The run fails immediately or early in the request lifecycle.
  4. A modal appears with:
    Error invoking remote method 'codesign:v1:generate': CodesignError: Unexpected end of JSON input

Actual

  • Generation aborts.
  • The user sees a raw JSON parse error.
  • The UI does not indicate which local file/state is malformed or how to recover.

Expected

  • Generate should not expose a raw Unexpected end of JSON input error to end users.
  • If a local JSON-backed state file is truncated/corrupt, the app should:
    • detect it,
    • report which state source failed,
    • recover safely when possible, or
    • show an actionable error message (for example: re-login, reset preferences, or repair local state).

Suspected area

This looks like an uncaught JSON.parse failure somewhere on the main-process generate path.

Relevant entry points / likely parse sites:

  • apps/desktop/src/main/index.ts codesign:v1:generate
  • packages/providers/src/codex/token-store.ts reads persisted ChatGPT Codex auth via JSON.parse
  • apps/desktop/src/main/preferences-ipc.ts reads preferences.json
  • other local JSON-backed state read during generate/bootstrap

One likely failure mode is a partially written or truncated local JSON file on Windows, with the raw parse error bubbling through IPC.

Why this matters

This is a poor recovery path for a user-visible flow:

  • it blocks generation completely,
  • the message is too low-level,
  • and it gives the user no clue which state file is broken or what action to take.

Suggested fix direction

  • Wrap all JSON reads reachable from generate with source-specific error handling.
  • Replace raw parse failures with structured CodesignErrors.
  • Include the failing store/source in logs.
  • Show a user-facing recovery hint instead of the raw parse message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:providerspackages/providers (pi-ai adapter, model calls)bugSomething isn't workingneeds-reproNeeds reproduction steps from reporter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions