Fix emptyable property serialization for third-party serializers#3366
Merged
jar-stripe merged 2 commits intomasterfrom Apr 15, 2026
Merged
Fix emptyable property serialization for third-party serializers#3366jar-stripe merged 2 commits intomasterfrom
jar-stripe merged 2 commits intomasterfrom
Conversation
Regenerated from sdk-codegen jar/emptyable-serialization-fix branch. Emptyable properties now have NullValueHandling.Ignore (Newtonsoft) and JsonIgnoreCondition.WhenWritingNull (STJ) annotations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
Fixes #3364. When a third-party serializer (e.g. AWS Lambda) serialized an Options object, unset emptyable properties were written as null. On deserialization the setter fired, SetTracker marked the property as explicitly set, and the SDK sent empty-string values to the API — unintentionally clearing fields. The fix is on the serialization side: emptyable properties now have NullValueHandling.Ignore and WhenWritingNull annotations (via codegen), so third-party serializers skip unset nulls. Also refactors STJDefaultConverter.Write to make the null-handling logic clearer: WhenWritingNull properties only write null when IsPropertySet is true, other properties follow the standard ignore condition. Adds round-trip tests covering Newtonsoft and STJ serialization paths. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
xavdid
approved these changes
Apr 15, 2026
Member
xavdid
left a comment
There was a problem hiding this comment.
fix looks good, but make sure to call out this behavior / pitfalls in the README!
This was referenced Apr 23, 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.
Why?
See #3364. When a third-party serializer (e.g. AWS Lambda) serializes an Options object, unset emptyable properties were written as
"mandate_data": null. On deserialization the setter fires,SetTracker.Track()marks the property as explicitly set, and the SDK sendsmandate_data=to the API — unintentionally clearing fields.The risk extends beyond Create calls — on Update APIs this could silently clear fields like
invoice_settingswithout the user realizing.What?
NullValueHandling.Ignore(Newtonsoft) andWhenWritingNull(STJ) annotations on emptyable properties, so third-party serializers skip unset nullsSTJDefaultConverter.Writenull-handling to dispatch on the property's ignore condition:WhenWritingNullproperties only write null whenIsPropertySetis trueTestOptionsto match the new codegen outputSee Also
Changelog