Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check Remap script result value type at compile-time #4862

Closed
JeanMertz opened this issue Nov 4, 2020 · 0 comments · Fixed by #4839
Closed

Check Remap script result value type at compile-time #4862

JeanMertz opened this issue Nov 4, 2020 · 0 comments · Fixed by #4839
Assignees
Labels
domain: vrl Anything related to the Vector Remap Language type: task Generic non-code related tasks

Comments

@JeanMertz
Copy link
Contributor

The Remap language returns its last expression as a value when executed. This value can be a string, bool, integer, etc.

When using Remap in the context of a so-called "condition" within Vector, such as:

[transforms.reduce]
	type = "reduce"
	ends_when.type = "remap"
	ends_when.source = "<source code here>"

The condition expects to receive a boolean, which determines if reduced logs are emitted.

Currently, any non-boolean value in a remap-conditional is considered to be "false". For example:

ends_when.source = 'upcase("foo")' # is interpreted by the conditional logic as "false"

Goal

The goal of this RFC is to make the above example a compile-time error. The user is forced to explicitly return a boolean value in a conditional, for example by using the to_bool function:

ends_when.source = 'to_bool(upcase("foo"), default = false)'

This should not apply to the remap transform, as its return value is ignored (its expressions are used to manipulate the event itself, not to return a final script value). The remap transform scripts should thus be allowed to return any value.

@JeanMertz JeanMertz added type: task Generic non-code related tasks domain: vrl Anything related to the Vector Remap Language labels Nov 4, 2020
@JeanMertz JeanMertz added this to the 2020-10-26: Recognizer milestone Nov 4, 2020
@JeanMertz JeanMertz self-assigned this Nov 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: vrl Anything related to the Vector Remap Language type: task Generic non-code related tasks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant