Skip to content

fix(sagemaker-core): preserve falsy values in serialize() output#5860

Open
ZealSV wants to merge 1 commit into
aws:masterfrom
ZealSV:bug/preserve-value-in-serialize
Open

fix(sagemaker-core): preserve falsy values in serialize() output#5860
ZealSV wants to merge 1 commit into
aws:masterfrom
ZealSV:bug/preserve-value-in-serialize

Conversation

@ZealSV
Copy link
Copy Markdown

@ZealSV ZealSV commented May 14, 2026

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.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

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.
@ZealSV ZealSV requested a deployment to manual-approval May 14, 2026 22:06 — with GitHub Actions Waiting
@ZealSV ZealSV requested a deployment to manual-approval May 14, 2026 22:06 — with GitHub Actions Waiting
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.

1 participant