fix(cli): handle network errors in version check gracefully#995
Open
berettavexee wants to merge 1 commit into
Open
fix(cli): handle network errors in version check gracefully#995berettavexee wants to merge 1 commit into
berettavexee wants to merge 1 commit into
Conversation
The GitHub API can return non-JSON responses (504, rate limit HTML page)
causing ContentTypeError to crash the CLI after a successful download.
- Pass content_type=None to resp.json() to skip MIME type validation
- Use gh.get("body") instead of gh["body"] in case the response is an
error object without that field
- Wrap the entire function in try/except so any network failure is
silently logged at DEBUG level and the check is skipped cleanly
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After a successful download, the CLI crashes with a traceback if the GitHub releases API returns a non-JSON response (504 gateway timeout, rate-limit HTML page, etc.):
Two root causes:
aiohttp'sresp.json()validates theContent-Typeheader and raisesContentTypeErroron anything other thanapplication/json.Fix
content_type=Noneto bothresp.json()calls to skip MIME type validation — the response is parsed as JSON regardless, and aJSONDecodeErroris caught by the outertry/exceptbelow.gh.get("body")instead ofgh["body"]to handle error responses from the GitHub API (rate-limit, 404, etc.) that don't include abodyfield.try/except Exceptionso any network failure (timeout, DNS, SSL, parse error) is logged atDEBUGlevel and the check is silently skipped — the version check should never interrupt or crash a download session.Test plan
body) → no crash, no notice🤖 Generated with Claude Code