Repository navigation
Accept null for the fields the API server may leave empty - #1595
Merged
Merged
Conversation
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.
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.
Breaking change
Station.ssl_error, andtimestamp,timing_msandssl_erroronStationCheck, can now beNone, as the API server declares them. Code that does arithmetic on them should handleNone.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 asnull, while the models required them:Stationssl_errorOption<u8>intStationChecktimestampOption<DateTime<Utc>>datetimeStationChecktiming_msOption<u128>intStationCheckssl_errorOption<u8>intA
nullin any of them made mashumaro reject the value, which fails the whole list. ForStation.ssl_errorthat is every station list, the endpoints Home Assistant relies on. Live data does not have such anullright 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
Optionfield of the server was already handled; I checked each one with anull.Type of change
Additional information
Checklist
poetry run pytestpasses locally. A pull request cannot be merged unless CI is green.poetry run prek run --all-filespasses (lint, format, and type checks).