Describe the issue/error/question
Code node is giving the error
ERROR: A 'json' property isn't an object when there’s no reason for it to. It can also be seen in the console that the json data seems to be properly structured.
Information on your n8n setup
n8n version: 0.216.0
Database you’re using (default: SQLite): Postgres
Running n8n with the execution process [own(default), main]: default
Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker
Upon further investigation, the input data’s structure (Array in the root level) in this case, seems to be responsible for this scenario (in conjunction with the Code node).
Incoming data's schema:
When i try the same thing with the old Function node, it works fine:
This should work fine in the Code node as well, right ?
Hi @shrey-42, I am sorry you’re having trouble. I just tried reproducing this on my end, but the Code node in the below example workflow runs fine for me on [email protected]:
Perhaps you can share an example workflow using which the problem can be reproduced rather than just a screenshot?
Hi @MutedJam. Sure, here’s the workflow:
This involves a custom node, Directus (n8n-nodes-directus - npm).
Will send you the credentials in a PM.
Thank you @shrey-42. Seeing I do not have this node, could you share the JSON output from this node so I can mock the output in the workflow?
The node is also installable as a community node.
But, here’s the node output as printed in the console, by the command
Hi @shrey-42, this looks like your custom node returns an invalid data structure.
This is no longer supported by the Code node and the value of
json has to be an object rather than an array (see Data structure - n8n Documentation for an example). So you’d need to change your node to return a suitable data structure. For example:
This structure would also work in the Code node:
Hi @MutedJam , thanks for the triage!
Will accommodate for this change.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.