Skip to content

Accept null for the fields the API server may leave empty - #1595

Merged
frenck merged 1 commit into
mainfrom
frenck/nullable-fields
Oct 2, 2026
Merged

frenck merged 1 commit into
mainfrom
frenck/nullable-fields

Conversation

@frenck

@frenck frenck commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Breaking change

Station.ssl_error, and timestamp, timing_ms and ssl_error on StationCheck, can now be None, as the API server declares them. Code that does arithmetic on them should handle None.

Proposed change

Found by going through the source of the API server itself (radiobrowser-api-rust, version 0.7.45, which is what the API runs). Its response structs declare a few fields as Option, so they can come back as null, while the models required them:

Model Field Server type Was
Station ssl_error Option<u8> int
StationCheck timestamp Option<DateTime<Utc>> datetime
StationCheck timing_ms Option<u128> int
StationCheck ssl_error Option<u8> int

A null in any of them made mashumaro reject the value, which fails the whole list. For Station.ssl_error that is every station list, the endpoints Home Assistant relies on. Live data does not have such a null right now (20,000 stations parse fine), but nothing on the server side prevents it.

The fields are now nullable. They stay required as keys, since the server always sends them, so the order of the fields does not change. Every other Option field of the server was already handled; I checked each one with a null.

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.

The API server declares Station.ssl_error, and the timestamp, timing and
SSL error of a check, as optional. A null in any of them failed the whole
list. Make them nullable.
@frenck frenck added the bugfix Inconsistencies or issues which will cause a problem for users or implementers. label Oct 2, 2026
@frenck
frenck merged commit fecb43f into main Oct 2, 2026
31 checks passed
@frenck
frenck deleted the frenck/nullable-fields branch October 2, 2026 07:54
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