Skip to content

Refuse responses that are not the list they should be - #1600

Merged
frenck merged 1 commit into
mainfrom
frenck/validate-response-shape
Oct 2, 2026
Merged

frenck merged 1 commit into
mainfrom
frenck/validate-response-shape

Conversation

@frenck

@frenck frenck commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Breaking change

A response that is not the list it should be now raises a RadioBrowserError instead of passing as an empty list. That only happens when the API, or something in between like a captive portal, sends a broken response.

Proposed change

A JSON object or a string where the API should send a list passed as an empty list, so a broken response looked like an empty result. A new list_from_json() refuses anything that is not a list, and every list endpoint uses it.

The API country names are cached for as long as the client lives. A country name that was not a string ended up in that cache and broke every later call. The cache is now only filled when every name is a string.

Both raise a RadioBrowserError, like any other unexpected response. Found in the fourth review round.

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

  • This PR fixes or closes issue: fixes # None
  • This PR is related to: None
  • Link to a separate documentation pull request: None

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.

@frenck frenck added the bugfix Inconsistencies or issues which will cause a problem for users or implementers. label Oct 2, 2026
An object or a string where a list belongs passed as an empty list,
hiding a broken response, and a country name that was not a string ended
up in the cache. Raise a RadioBrowserError for both.
@frenck
frenck force-pushed the frenck/validate-response-shape branch from a5dd74a to 4af204b Compare October 2, 2026 09:07
@frenck
frenck merged commit d80e105 into main Oct 2, 2026
30 checks passed
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