fix(stdlib): validate tdef against runtime value and fix incorrect type_defs#1823
Draft
thomasqueirozb wants to merge 2 commits into
Draft
fix(stdlib): validate tdef against runtime value and fix incorrect type_defs#1823thomasqueirozb wants to merge 2 commits into
thomasqueirozb wants to merge 2 commits into
Conversation
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
The
test_function!macro now validates that the declaredtdefis actually a superset of the kind of the runtimewantvalue. This catches cases wheretype_def()returns a type too narrow to cover all values the function can produce.The validation exposed real bugs across many stdlib functions, all of which are fixed here:
merge: deep merge now correctly includes fields from both objects (previously lostto's sub-object fields)round:type_def()now returns float for float inputs, integer for integer inputs (was always integer)xxhash:type_def()now returnsbytes | integer(was bytes-only, but XXH32/64/3-64 return integers)parse_tokens: array unknown type now includes nullpop/slice: useresolve_constantto compute the exact output type when inputs are literalsparse_regex/parse_regex_all: whennumeric_groups=false(default), numeric-index capture groups are excluded from the typeparse_syslog,parse_apache_log,parse_aws_alb_log,parse_aws_vpc_flow_log,parse_common_log,parse_nginx_log,parse_influxdb,parse_xml: field types corrected and optional fields marked with| undefinedChange Type
Is this a breaking change?
How did you test this PR?
Full
cargo test -p vrl --libpasses (1846 tests, 0 failures).Does this PR include user facing changes?
Checklist
dd-rust-license-tool writeand commit the changes. More details here.References
NA