Commit 2d3adfe
committed
fix(boxlite/rest): tolerate legacy server cpus/memory_mib past SDK narrow types
list_info kept blowing up with
RuntimeError: ... invalid value: integer 999, expected u8
or
RuntimeError: ... invalid value: integer 8192000000, expected u32
on the Tokyo e2e stack because the Box table still carries pre-#735
rows that the API created back when the per-box quota wasn't enforced
(cpus=999, memory_mib past 4 GiB). serde_json's narrow integer
deserializer aborts the whole list response when ANY row's cpu or
memory exceeds the field's range, so a single bad row poisoned every
test_list_info* / test_runtime_initialization_*.
Widen the on-the-wire deserialization (BoxResponse.cpus: u32,
BoxResponse.memory_mib: u64) so the boundary accepts whatever the
server returns, then saturate-cast at the SDK boundary
(BoxInfo.cpus: u8, BoxInfo.memory_mib: u32 are the long-standing
public types and bindings rely on them). Legitimate values
round-trip unchanged; legacy garbage clamps to the narrow type's
MAX instead of crashing the list call.
Two-side verified against
cargo test -p boxlite --features rest test_box_response_legacy_oversize_cpus_memory_does_not_break_list
- impl reverted to the prior narrow types → test FAILS at from_str
with the exact production error
'invalid value: integer 999, expected u8'.
- impl restored → all 5 box_response tests pass.1 parent d35cbe4 commit 2d3adfe
1 file changed
Lines changed: 48 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
202 | | - | |
203 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
204 | 213 | | |
205 | 214 | | |
206 | 215 | | |
| |||
236 | 245 | | |
237 | 246 | | |
238 | 247 | | |
239 | | - | |
240 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
241 | 254 | | |
242 | 255 | | |
243 | 256 | | |
| |||
642 | 655 | | |
643 | 656 | | |
644 | 657 | | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
645 | 689 | | |
646 | 690 | | |
647 | 691 | | |
| |||
0 commit comments