fix: boolean handler must not coerce None or empty-string to False#196
Open
afkerhousse wants to merge 1 commit intosinger-io:masterfrom
Open
fix: boolean handler must not coerce None or empty-string to False#196afkerhousse wants to merge 1 commit intosinger-io:masterfrom
afkerhousse wants to merge 1 commit intosinger-io:masterfrom
Conversation
transform_recur always moves null to the end of the type list so that
null is tried last. For a schema type ["null", "boolean"] this means
boolean is attempted first.
The boolean handler previously reached bool(None) = False and returned
(True, False) without raising, so the null handler was never reached.
The same applied to empty strings: bool("") = False.
As a result, any field typed ["null", "boolean"] whose API value was
None or "" was silently written as false instead of null, corrupting
data in every downstream destination.
Fix: return (False, None) early in the boolean handler when data is
None or "", allowing transform_recur to fall through to the null
handler which correctly returns (True, None).
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.
Summary
transform_recuralways moves"null"to the end of the type list so it is tried last. For a schema typed["null", "boolean"]this meansbooleanis attempted first.The
booleanhandler fell through tobool(data)which:bool(None)→False— no exception raised → returns(True, False)✗bool("")→False— no exception raised → returns(True, False)✗In both cases the null handler is never reached, so any field typed
["null", "boolean"]whose API value isNoneor""is silently written asfalseinstead ofnull.This is a silent data corruption bug: null values are replaced with
falsein every destination without any schema mismatch error being raised.Reproduction
Fix
Return
(False, None)early in thebooleanhandler whendata is None or data == "", sotransform_recurfalls through to thenullhandler which correctly returns(True, None).Impact
Any tap that syncs a nullable boolean field from an API that returns
nullor""for unset values is affected. Confirmed reproduction via tap-hubspot contacts stream after its migration to the HubSpot CRM v3 API, where the API documentation explicitly states unset properties are returned asnull.Test plan
transform(None, {"type": ["null", "boolean"]}, {})returnsNonetransform("", {"type": ["null", "boolean"]}, {})returnsNonetransform(True, {"type": ["null", "boolean"]}, {})returnsTruetransform(False, {"type": ["null", "boolean"]}, {})returnsFalsetransform("true", {"type": ["null", "boolean"]}, {})returnsTruetransform("false", {"type": ["null", "boolean"]}, {})returnsFalsetransform(None, {"type": "boolean"}, {})still raisesSchemaMismatch(non-nullable field)🤖 Generated with Claude Code