Skip to content

Raise a RadioBrowserError for responses that cannot be decoded - #1575

Merged
frenck merged 1 commit into
mainfrom
frenck/wrap-decode-errors
Oct 1, 2026
Merged

frenck merged 1 commit into
mainfrom
frenck/wrap-decode-errors

Conversation

@frenck

@frenck frenck commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Breaking change

None.

Proposed change

Found in a second review of the library. #1566 wrapped JSON and model errors in a RadioBrowserError, but decoding the body happens earlier, in response.text(). A body that does not match the encoding the server claims (invalid UTF-8 in a charset=utf-8 response) still leaked a raw UnicodeDecodeError from every public method.

That is a broken response, so it now raises a RadioBrowserError with the original error as its cause. Like the other broken responses, it is not retried.

Type of change

  • Dependency or tooling upgrade
  • Bugfix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Deprecation (replaces or removes a feature, with a migration path)
  • Breaking change (a fix or feature that changes existing behavior)
  • Code quality, refactor, or test-only change
  • Documentation only

Additional information

Checklist

  • I fully understand the code in this pull request and can explain every line, including any AI-assisted changes.
  • The change is covered by tests, and poetry run pytest passes locally. A pull request cannot be merged unless CI is green.
  • poetry run prek run --all-files passes (lint, format, and type checks).
  • No commented-out or dead code is left in the pull request.

A body that does not match the encoding the server claims leaked a raw
UnicodeDecodeError from response.text(). Treat it like any other broken
response.
@frenck frenck added the bugfix Inconsistencies or issues which will cause a problem for users or implementers. label Oct 1, 2026
@frenck
frenck merged commit 8086c86 into main Oct 1, 2026
31 checks passed
@frenck
frenck deleted the frenck/wrap-decode-errors branch October 1, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Inconsistencies or issues which will cause a problem for users or implementers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant