fix(sagemaker-core): preserve falsy values in serialize() output#5860
Open
ZealSV wants to merge 1 commit into
Open
fix(sagemaker-core): preserve falsy values in serialize() output#5860ZealSV wants to merge 1 commit into
ZealSV wants to merge 1 commit into
Conversation
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.
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.
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 Nonecheck. 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.