GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing github.com — fix(storage): handle empty JSON files gracefully by coleleavitt · Pull Request #7888 · anomalyco/opencode Conversation
|
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate Found: PR #7618: fix(sdk): improve JSON parsing error handling with contextual messages Why it's related: This PR also addresses JSON parsing errors in the SDK. Both PRs are fixing issues with JSON parsing in the SDK client, though PR #7618 appears to focus on error handling with contextual messages while PR #7888 (the current PR) specifically handles empty response bodies. These may be tackling related or overlapping issues in the same codebase area. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Fixes 'Unexpected end of JSON input' error when server returns empty body.
Root cause: OPTIONS handler at /zen/v1/models returned status 200 with null body,
but SDK only handled empty responses for status 204 or Content-Length: 0.
Changes:
- Server: OPTIONS handler now returns 204 (No Content) instead of 200
- SDK (v1 & v2): JSON parsing now reads text first and handles empty bodies
by returning {} instead of failing on response.json()
2ed9637 to
2b848ef
Compare
|
Created issue #7889 to track this bug. PR description updated with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
After Anthropic OAuth login, sync.data.agent is empty while data loads. This caused crashes when accessing local.agent.current().name before agents were populated. Changes: - Make agentStore.current nullable with optional chaining on init - Add fallback to first agent in current() when not found - Add early return guards in submit(), cycle(), cycleFavorite(), set() - Add null checks in highlight(), spinnerDef() memos - Use optional chaining in JSX for agent name display
|
@coleleavitt the client crash will be fixed upstream hey-api/hey-api#3202 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
- Check for empty files before parsing to avoid 'Unexpected end of JSON input' error - Throw NotFoundError instead of JSON parse error for empty files - Apply fix to both read() and update() functions
- Add null byte/control character detection in storage read/update - Wrap JSON.parse in try-catch with descriptive error messages - Make stats command resilient to corrupted files by catching errors - Fixes 'JSON Parse error: Unterminated string' crashes in stats command
Additional Fix: Corrupted File DetectionAdded comprehensive error handling for corrupted JSON files containing null bytes or control characters. New Changes (commit 061652e)Problem Found:
Solution:
Testing:
This prevents the "JSON Parse error: Unterminated string" crash that occurred with corrupted storage files. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@coleleavitt do you think this check also belongs upstream? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
cc @coleleavitt ^ |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Closing - the main issue (SDK crash on empty responses) was fixed upstream via the hey-api update in PR #8921. The storage layer fixes for corrupted local files are nice-to-have but not critical enough to warrant a separate PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
SDK throws 'Unexpected end of JSON input' on empty response bodies Unexpected end of json
There was an error while loading. Please reload this page.