n8n-io/n8n · error · NodeOperationError
The provided workflow is not valid JSON: "${(error as Error)
Error message
The provided workflow is not valid JSON: "${(error as Error).message}" What it means
Thrown by the Call Workflow Tool v1 when 'Source' is 'Parameter' and the supplied workflowJson string fails JSON.parse. The tool tries to load a sub-workflow definition inline from the parameter, and an unparseable definition cannot be executed.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/v1/ToolWorkflowV1.node.ts:81
const { value } = this.getNodeParameter(
'workflowId',
itemIndex,
{},
) as INodeParameterResourceLocator;
workflowInfo.id = value as string;
}
subWorkflowId = workflowInfo.id;
} else if (source === 'parameter') {
// Read workflow from parameter
const workflowJson = this.getNodeParameter('workflowJson', itemIndex) as string;
try {
workflowInfo.code = JSON.parse(workflowJson) as IWorkflowBase;
// subworkflow is same as parent workflow
subWorkflowId = workflowProxy.$workflow.id;
} catch (error) {
throw new NodeOperationError(
this.getNode(),
`The provided workflow is not valid JSON: "${(error as Error).message}"`,
{
itemIndex,
},
);
}
}
const rawData: IDataObject = { query };
const workflowFieldsJson = this.getNodeParameter('fields.values', itemIndex, [], {
rawExpressions: true,
}) as SetField[];
// Copied from Set Node v2
for (const entry of workflowFieldsJson) {
if (entry.type === 'objectValue' && (entry.objectValue as string).startsWith('=')) {View on GitHub (pinned to 5ac6606e81)
Solutions
- Re-export the target workflow from n8n (⋯ → Download) and paste the full, unedited JSON.
- Paste the workflowJson value into a JSON linter and fix the reported syntax error.
- Switch 'Source' from 'Parameter' to 'Database' and select the workflow by ID instead.
Example fix
// before: workflowJson = '{ "nodes": [ ' (truncated)
// after: re-download and paste the complete workflow JSON,
// or set Source = 'Database' and pick the workflow by ID. Defensive patterns
Strategy: validation
Validate before calling
const workflowJson = this.getNodeParameter('workflowJson', itemIndex) as string;
try { JSON.parse(workflowJson); }
catch (e) { throw new Error(`workflowJson is not valid JSON: ${e.message}`); } Type guard
function isParsableWorkflowJson(s: string): boolean {
try { JSON.parse(s); return true; } catch { return false; }
} Try / catch
try { workflowInfo.code = JSON.parse(workflowJson); }
catch (error) { /* show fix-JSON guidance to user */ } Prevention
- Always download workflow exports from n8n rather than hand-writing them.
- Validate pasted JSON in a linter before saving the node.
- Prefer 'Database' source over 'Parameter' to avoid inline JSON.
When it happens
Trigger: Pasting a workflow export whose JSON is malformed (truncated, edited by hand, contains expression syntax that breaks parsing); copying only part of a workflow JSON.
Common situations: Manually editing the workflow JSON parameter; pasting from a source that introduced smart quotes or stripped braces; truncation when copying a large workflow.
Related errors
- The provided workflow is not valid JSON: "${(error as Error)
- Could not replace placeholders in ${key}: ${error.message}
- Error during parsing of JSON Schema. ${error}
- Failed to read prebuilt-workflows manifest at ${path}: ${msg
- Additional Model Request Fields must be valid JSON
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/d29e0f2e8f22cba8.
Report an issue: GitHub.