-
Notifications
You must be signed in to change notification settings - Fork 30
Closed
Description
Describe the bug
The condition package inaccurately matches on zero values for some number and string functions when the path doesn't exist in an object. This is due to null conversion between types (null is converted to 0 if interpreted as an integer, 0.0 if interpreted as a float, "" if interpreted as a string, false if interpreted as a bool).
To Reproduce
Run these tests:
{
tests: [
// This should not return true.
{
name: "number_conversion",
transforms: [
sub.tf.test.message({ value: {bar: null, baz: 0} }),
],
condition: sub.cnd.num.eq({ object: { source_key: "foo" }, value: 0 }),
},
// This should not return true.
{
name: "string_conversion",
transforms: [
sub.tf.test.message({ value: {bar: null, baz: 0} }),
],
condition: sub.cnd.str.eq({ object: { source_key: "foo" }, value: "" }),
},
],
transforms: [
sub.tf.send.stdout(),
]
}Expected behavior
These should return False. This may not apply to every number and string function (ex. if the path doesn't exist, then a length of zero or a regexp of ^$ is accurate).
Screenshots
N/A
Build (please complete the following information):
- Version v2.2.0
Cloud (please complete the following information):
N/A
Additional context
N/A
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels