Change coerce_type default to True for JsonData/EntityJson#4
Merged
Conversation
JSON payloads are inherently loosely typed — BigIntegers become strings,
booleans appear where strings are expected, etc. Requiring exact type
matches by default causes InvalidJsonType errors that silently disable
rules (11.6M+ Sentry events).
With coerce_type=True by default, the engine attempts to convert the
value to the declared type (e.g., int("123") or str(False)). If
coercion fails, InvalidJsonType is still raised.
This affects both JsonData and EntityJson (EntityJsonArguments inherits
from json_data.Arguments).
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
Change
coerce_typedefault fromFalsetoTrueinJsonData(and by inheritance,EntityJson).Why
JSON payloads are inherently loosely typed — BigIntegers become strings (
bigint_as_string=True), booleans appear where strings are expected, etc. Requiring exact type matches by default causesInvalidJsonTypeerrors that silently disable rules.With
coerce_type=Trueby default, the engine attemptsint("123"),str(False), etc. If coercion fails (e.g.,int("hello")),InvalidJsonTypeis still raised — so genuinely wrong types are still caught.This eliminates an entire class of rule-authoring footguns. Rule authors no longer need to remember
coerce_type=Truefor every snowflake ID, every field that might be a bool vs string, etc.Risk
Low. Coercion only applies when the value exists but has the wrong type. If coercion succeeds, the rule gets the right value. If coercion fails, the same
InvalidJsonTypeerror fires. No behavior change for rules where types already match.Test plan
test_execute_coerce_typetests still passInvalidJsonTypeSentry events decrease