{"record":{"id":"d29e0f2e8f22cba8","repo":"n8n-io/n8n","slug":"the-provided-workflow-is-not-valid-json-error-d29e0f","errorCode":null,"errorMessage":"The provided workflow is not valid JSON: \"${(error as Error).message}\"","messagePattern":"The provided workflow is not valid JSON: \"(.+?)\"","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/v1/ToolWorkflowV1.node.ts","lineNumber":81,"sourceCode":"\t\t\t\t\tconst { value } = this.getNodeParameter(\n\t\t\t\t\t\t'workflowId',\n\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\t{},\n\t\t\t\t\t) as INodeParameterResourceLocator;\n\t\t\t\t\tworkflowInfo.id = value as string;\n\t\t\t\t}\n\n\t\t\t\tsubWorkflowId = workflowInfo.id;\n\t\t\t} else if (source === 'parameter') {\n\t\t\t\t// Read workflow from parameter\n\t\t\t\tconst workflowJson = this.getNodeParameter('workflowJson', itemIndex) as string;\n\t\t\t\ttry {\n\t\t\t\t\tworkflowInfo.code = JSON.parse(workflowJson) as IWorkflowBase;\n\n\t\t\t\t\t// subworkflow is same as parent workflow\n\t\t\t\t\tsubWorkflowId = workflowProxy.$workflow.id;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t\t`The provided workflow is not valid JSON: \"${(error as Error).message}\"`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst rawData: IDataObject = { query };\n\n\t\t\tconst workflowFieldsJson = this.getNodeParameter('fields.values', itemIndex, [], {\n\t\t\t\trawExpressions: true,\n\t\t\t}) as SetField[];\n\n\t\t\t// Copied from Set Node v2\n\t\t\tfor (const entry of workflowFieldsJson) {\n\t\t\t\tif (entry.type === 'objectValue' && (entry.objectValue as string).startsWith('=')) {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/v1/ToolWorkflowV1.node.ts#L63-L99","documentation":"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.","triggerScenarios":"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.","commonSituations":"Manually editing the workflow JSON parameter; pasting from a source that introduced smart quotes or stripped braces; truncation when copying a large workflow.","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."],"exampleFix":"// before: workflowJson = '{ \"nodes\": [ ' (truncated)\n// after: re-download and paste the complete workflow JSON,\n// or set Source = 'Database' and pick the workflow by ID.","handlingStrategy":"validation","validationCode":"const workflowJson = this.getNodeParameter('workflowJson', itemIndex) as string;\ntry { JSON.parse(workflowJson); }\ncatch (e) { throw new Error(`workflowJson is not valid JSON: ${e.message}`); }","typeGuard":"function isParsableWorkflowJson(s: string): boolean {\n  try { JSON.parse(s); return true; } catch { return false; }\n}","tryCatchPattern":"try { workflowInfo.code = JSON.parse(workflowJson); }\ncatch (error) { /* show fix-JSON guidance to user */ }","preventionTips":["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."],"tags":["workflow-tool","json","configuration","ai-tool"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}