Repository navigation
bug: Win11 generate can fail with raw 'Unexpected end of JSON input' #128
Copy link
Copy link
Closed
Labels
area:providerspackages/providers (pi-ai adapter, model calls)packages/providers (pi-ai adapter, model calls)bugSomething isn't workingSomething isn't workingneeds-reproNeeds reproduction steps from reporterNeeds reproduction steps from reporter
Description
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
- Open open-codesign on Windows 11.
- Start a normal generation.
- The run fails immediately or early in the request lifecycle.
- 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 inputerror 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.tscodesign:v1:generatepackages/providers/src/codex/token-store.tsreads persisted ChatGPT Codex auth viaJSON.parseapps/desktop/src/main/preferences-ipc.tsreadspreferences.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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:providerspackages/providers (pi-ai adapter, model calls)packages/providers (pi-ai adapter, model calls)bugSomething isn't workingSomething isn't workingneeds-reproNeeds reproduction steps from reporterNeeds reproduction steps from reporter
Activity
github-actions commentedon Apr 22, 2026
Thanks for the detailed report — this is helpful.
I checked the current code path and your diagnosis looks valid for the ChatGPT Codex route:
codesign:v1:generatecallsrunCodexGenerate(...)when provider ischatgpt-codex, and rethrows errors from that path as-is.CodexTokenStore.read()parsescodex-auth.jsonwithJSON.parse, but on parse failure it throws a plainError("Invalid Codex token store at ...")(not a structuredCodesignError).err.messagedirectly in UI/toast, so low-level parse failures can reach users.Relevant code:
apps/desktop/src/main/index.ts:505—codesign:v1:generatehandlerapps/desktop/src/main/codex-generate.ts:211— Codex generate path reads token storepackages/providers/src/codex/token-store.ts:72—JSON.parseof persisted authpackages/providers/src/codex/token-store.ts:74— parse failure throws plainErrorapps/desktop/src/renderer/src/store.ts:856— generation error uses rawerr.messageapps/desktop/src/main/preferences-ipc.ts:90—preferences.jsonread failures are already wrapped (PREFERENCES_READ_FAILED)Also for context: the app is still in early
v0.1.xpolish (README currently saysv0.1.3), so some recovery/diagnostics paths are still being hardened.Need more info:
chatgpt-codex?v0.1.3)?%USERPROFILE%\\.config\\open-codesign\\codex-auth.jsonexists and looks truncated/partial?open-codesign Bot
fix(codex): wrap token-store JSON parse errors and use atomic write (#…
fix(codex): use randomUUID in atomic write tmp path to avoid intra-pr…
fix(codex): wrap token-store JSON parse errors and use atomic write (O…