fix: tolerate null response_id from the Timeweb API#18
Merged
Merged
Conversation
The shared `response_id` schema is required in the response wrappers, but the live API returns null on some endpoints (e.g. GET /account/finances), breaking deserialization with "invalid type: null, expected a formatted UUID string". `openapi/normalize_spec.py` now marks `response_id` nullable, so the regenerated models type it as `Option<uuid::Uuid>`.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Bug
GET /api/v1/account/finances(and other endpoints) returnsresponse_id: null, but the generated models typedresponse_idas a requireduuid::Uuid. Deserialization fails:Any consumer calling
payments_api::get_financesgets a hard error even thoughfinancesitself is valid.Root cause
The upstream spec types
components/schemas/response_idas{ type: string, format: uuid }and lists it in the response wrappers'required, so the generator emitsresponse_id: uuid::Uuidacross the models. The live API does not honour that contract — it can sendnull.Fix
openapi/normalize_spec.pynow marks the sharedresponse_idschema (and any inline occurrence)nullable: truebefore generation. Regenerated models typeresponse_idasOption<uuid::Uuid>— required occurrences viaOption::deserialize, optional ones viadouble_option— so anulldeserializes toNone.Regenerated with the pinned generator (7.22.0) +
cargo +nightly fmt, exactly asspec-sync.ymldoes; the diff is response_id-only.Tests
Added
tests/response_id_nullable.rs: a finances response withresponse_id: nulldeserializes toNone, and one with a UUID still parses.Gates
cargo +nightly fmt --checkcargo clippy --all-targets --all-features -- -W clippy::pedantic -W clippy::nursery -D warnings(0)cargo test --all-featurescargo build --all-featuresCloses #17