Commit 4171658
authored
fix(sagemaker-core): preserve falsy values in serialize() output (#5860)
The walrus check in _serialize_dict and _serialize_list silently dropped
False / 0 / "" along with None / Unassigned, because all of them are
falsy. Boolean parameters that should reach the wire as False were
instead omitted, causing the server to apply its own default (often
True), which led to confusing validation errors that contradicted the
caller's input.
Concrete failure: AIRecommendationJob.create(optimize_model=False)
silently sent OptimizeModel=True, then failed with a server message
about a missing DatasetConfig — a requirement that only applies when
OptimizeModel is True.
Replace the walrus truthy guard with an explicit `is not None` check.
serialize() already returns None for both None and Unassigned (utils.py
line 512), so this preserves the "drop unset fields" semantics while
correctly retaining valid falsy payloads.
Adds two regression tests covering False / 0 / "" preservation and
None / Unassigned removal.1 parent bb0b615 commit 4171658
2 files changed
Lines changed: 21 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
538 | 538 | | |
539 | 539 | | |
540 | 540 | | |
| 541 | + | |
541 | 542 | | |
542 | | - | |
543 | | - | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
544 | 546 | | |
545 | 547 | | |
546 | 548 | | |
| |||
555 | 557 | | |
556 | 558 | | |
557 | 559 | | |
| 560 | + | |
558 | 561 | | |
559 | | - | |
| 562 | + | |
| 563 | + | |
560 | 564 | | |
561 | 565 | | |
562 | 566 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
356 | 370 | | |
357 | 371 | | |
358 | 372 | | |
| |||
0 commit comments