Open
Description
body = del(.)
for_each(["test1"]) -> |key, path| {
., err = set(., ["new", path], "test1")
}
.new.test2 = "test2"
this VRL program fails in compiling because of type of .new
. (VRL Playground Link)
Error Log
error[E642]: parent path segment rejects this mutation
┌─ :5:6
│
5 │ .new.test2 = "test2"
│ ---- ^^^^^ querying a field of a non-object type is unsupported
│ │
│ this path resolves to a value of type undefined
│
= try: change parent value to object, before assignment
=
= .new = {}
= .new.test2 = "test2"
=
= see documentation about error handling at https://errors.vrl.dev/#handling
= see language documentation at https://vrl.dev
= try your code in the VRL REPL, learn more at https://vrl.dev/examples
However, if it's inside an if statement instead of for_each, this vrl program can be compiled.
body = del(.)
if is_boolean(body.message) {
., err = set(., ["new", "test1"], "test1")
}
.new.test2 = "test2"
My theory is that .
's type is not changed by the for_each statement, which looks like a bug.