Skip to content

fix: tolerate null response_id from the Timeweb API#18

Merged
RAprogramm merged 1 commit into
mainfrom
17
May 28, 2026
Merged

fix: tolerate null response_id from the Timeweb API#18
RAprogramm merged 1 commit into
mainfrom
17

Conversation

@RAprogramm

Copy link
Copy Markdown
Owner

Bug

GET /api/v1/account/finances (and other endpoints) returns response_id: null, but the generated models typed response_id as a required uuid::Uuid. Deserialization fails:

invalid type: null, expected a formatted UUID string

Any consumer calling payments_api::get_finances gets a hard error even though finances itself is valid.

Root cause

The upstream spec types components/schemas/response_id as { type: string, format: uuid } and lists it in the response wrappers' required, so the generator emits response_id: uuid::Uuid across the models. The live API does not honour that contract — it can send null.

Fix

openapi/normalize_spec.py now marks the shared response_id schema (and any inline occurrence) nullable: true before generation. Regenerated models type response_id as Option<uuid::Uuid> — required occurrences via Option::deserialize, optional ones via double_option — so a null deserializes to None.

Regenerated with the pinned generator (7.22.0) + cargo +nightly fmt, exactly as spec-sync.yml does; the diff is response_id-only.

Tests

Added tests/response_id_nullable.rs: a finances response with response_id: null deserializes to None, and one with a UUID still parses.

Gates

  • cargo +nightly fmt --check
  • cargo clippy --all-targets --all-features -- -W clippy::pedantic -W clippy::nursery -D warnings (0)
  • cargo test --all-features
  • cargo build --all-features

Closes #17

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

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@RAprogramm RAprogramm merged commit 22c988d into main May 28, 2026
12 checks passed
@RAprogramm RAprogramm deleted the 17 branch May 28, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: response_id must be nullable — Timeweb returns null on some responses

1 participant