Fix VersionInfo to match real /api/version responses#165
Merged
Conversation
The TypedDict listed `version` and `sdk` (per OpenAPI spec) as required strings and `firmware`/`printer` as required, but the bundled PrusaLink in Prusa-Firmware-Buddy never returns `version`/`sdk`, and only added `firmware`/`printer` in v6.5.1 (Core One L) — the field is absent on: - All firmware before v6.5.1 - XL track (currently on 6.4.x) - MINI (last release was 6.4.0) It also omitted `server`, `hostname`, and `nozzle_diameter` which the bundled firmware always returns. Update VersionInfo to mark every field except `api` as optional, and add docstring documenting field availability per firmware. Update test_get_version to use realistic modern firmware data and add test_get_version_legacy_firmware covering the absence case. Reference: prusa3d/Prusa-Firmware-Buddy@64b7a21 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
agners
requested changes
May 7, 2026
Match the convention used by Storage and Transfer. The OpenAPI spec for /api/version does not declare any field as required, so we mark only `api` as required (it is the API version itself, returned by every PrusaLink variant we know of). Every other field is `NotRequired`, even fields that bundled firmware always returns (server, hostname, nozzle_diameter, text, capabilities) — we cannot assume the same for standalone PrusaLink installations on RPi. Also include @agners' MK4 firmware 6.4.0 response as a concrete example in the docstring of what older firmware returns (no firmware/printer fields). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
@agners Thanks for all the good feedback on doing this first pass on updates and getting this in a better state. I suggest releasing a 2.2.0 when #165 is merged. Further pipeline:
|
agners
requested changes
May 7, 2026
Test absence of NotRequired keys via `not in` instead of `.get() is None` `not in` is the precise assertion for NotRequired semantics — the key is genuinely absent rather than present with a None value. Co-authored-by: Stefan Agner <stefan@agner.ch>
agners
approved these changes
May 7, 2026
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.
Summary
VersionInfolisted fields as required that the bundled PrusaLink in Prusa-Firmware-Buddy never returns (version,sdk) or only returns conditionally (firmware,printer). It also omitted three fields the bundled firmware always returns (server,hostname,nozzle_diameter).Field availability matrix
firmwareandprinterwere added to bundled PrusaLink in64b7a21(BFW-7864):firmware/printerModels still without the fields on their latest firmware: XL (6.4.x), MINI (last release 6.4.0).
versionandsdkare in the Prusa-Link-Web OpenAPI spec but never returned by bundled firmware — kept as optional in case standalone PrusaLink (RPi) returns them.Changes
pyprusalink/types.py: every field onVersionInfoexceptapiis now optional. Added docstring documenting which firmware versions return which fields.tests/test_prusalink.py: updatedtest_get_versionto use realistic Core One 6.5.3 data; addedtest_get_version_legacy_firmwarecovering the case where the printer doesn't returnfirmware/printer.Test plan
pytest tests/firmwarefield — confirmed via firmware source code analysis🤖 Generated with Claude Code