After running a subworkflow I receive a json object. If i try to make a simple edit using node code, i get an error for the JSON output: Invalid output format [item 0] An output item contains the reserved key json. To get around this, please wrap each item in an object, under a key called json.
The only solution i found was to delete the metadata key from the item.
I believe this is not expected behaviour.
for (const item of $input.all()) { delete item.metadata; } return $input.all();
Please share your workflow
Share the output returned by the last node
Invalid output format [item 0]
An output item contains the reserved key json. To get around this, please wrap each item in an object, under a key called json.
Hi @jgggr
The Execute Sub-workflow node adds a top-level metadata key to every item it returns, which is what the “View sub-execution” link uses, and the Code node only allows json, binary, pairedItem and error as top-level keys on an output item, so return $input.all() gets rejected. Build the output items instead of returning the input ones:
Same idea, and for the items that actually get cleaned the outcome is identical. The version in the workflow JSON you pasted isn’t equivalent though: delete item.metadata sits inside the case "example": branch, so only items whose agent_name matches get cleaned and every other item still carries metadata and trips the same error. Building the output item covers all of them without a branch, and it keeps working if the node ever returns another top-level key alongside metadata.