Open torfjor opened 9 months ago
Hey @torfjor, the documentation is outdated and pretty unhelpful but the behaviour is "correct" in the sense that it's intentional. Within a traditional mapping the new message being created, and the message that is being fed into the mapping, are the same, and so @
syntax only differs from the metadata
(and meta
) function in so far as changes made within the mapping are not reflected by the metadata
function as it references a read-only instance of the source message.
The result_map
works slightly differently, as the message being created is a mutation of the message as it was before the branch processors were enacted, and the message being fed into the mapping is the newly created message that resulted from the branch processors. This means that @
and metadata
can yield entirely different metadata values as one is reading from the old message and one is reading from the new one.
We have a small section on the branch page that briefly explains the behaviour: https://www.benthos.dev/docs/components/processors/branch#metadata. However, the docs reference the older meta
function and it could definitely do with being fleshed out a bit.
This works:
Whereas this does not:
Am I holding the tool wrong, or is this a bug?