Skip to content

Fix JSONDecodeError crash in check_connectivity for non-JSON responses - #5

Draft
obnoxiousmods with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-json-decode-error
Draft

obnoxiousmods with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-json-decode-error

Conversation

Copilot AI commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

check_connectivity() calls r.json() on the /System/Info/Public response without checking the status code or handling parse failures. Any non-Jellyfin service, reverse proxy, wrong port (e.g. 8086 vs 8096), or empty response body crashes with an unhandled JSONDecodeError.

Changes

  • Validate status code before parsing: non-200 from /System/Info/Public exits with actionable guidance instead of blindly calling .json()
  • Catch JSONDecodeError/ValueError: logs response body snippet and common causes (wrong port, reverse proxy, non-Jellyfin service)
  • Handle connection/timeout errors on /System/Info: previously only the public endpoint had these handlers; the authenticated endpoint would raise uncaught
  • Add HTTP 403 handling: distinguish "key rejected" (401) from "key lacks admin privileges" (403)

Tests

13 new tests in test_connectivity.py covering: success path, empty body, HTML response, non-200 status codes, connect errors, timeouts, and all auth failure modes on both endpoints.

…and tests

- Handle non-200 status codes from /System/Info/Public before JSON parse
- Catch JSONDecodeError/ValueError with actionable error messages
- Add ConnectError/TimeoutException handling for /System/Info endpoint
- Add HTTP 403 handling for API key permission issues
- Add 13 connectivity tests covering all error scenarios

Agent-Logs-Url: https://github.com/obnoxiousmods/jellyfinCleaner/sessions/aa0d815f-0525-4f03-9cbb-61e83ee0d35d

Co-authored-by: obnoxiousmods <18523901+obnoxiousmods@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix JSONDecodeError in jellyfin-cleanup Fix JSONDecodeError crash in check_connectivity for non-JSON responses Apr 8, 2026
Copilot AI requested a review from obnoxiousmods April 8, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

raise JSONDecodeError("Expecting value", s, err.value) from None

2 participants