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 WorkflowToolService.getSubWorkflowInfo (v2) when 'Source' is 'Parameter' and JSON.parse of the workflowJson parameter fails. Identical cause to the v1 equivalent (error 750): an inline workflow definition that isn't valid JSON.

Source

Thrown at packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.ts:358

		const workflowInfo: IExecuteWorkflowInfo = {};
		let subWorkflowId: string;

		if (source === 'database') {
			const { value } = context.getNodeParameter(
				'workflowId',
				itemIndex,
				{},
			) as INodeParameterResourceLocator;
			workflowInfo.id = value as string;
			subWorkflowId = workflowInfo.id;
		} else if (source === 'parameter') {
			const workflowJson = context.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(
					context.getNode(),
					`The provided workflow is not valid JSON: "${(error as Error).message}"`,
					{ itemIndex },
				);
			}
		}

		return { workflowInfo, subWorkflowId: subWorkflowId! };
	}

	private prepareRawData(
		context: ISupplyDataFunctions | IExecuteFunctions,
		query: string | IDataObject,
		itemIndex: number,
	): IDataObject {
		const rawData: IDataObject = { query };
		const workflowFieldsJson = context.getNodeParameter('fields.values', itemIndex, [], {
			rawExpressions: true,

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Re-download the workflow JSON from n8n and paste it unedited.
  2. Validate the JSON in a linter and fix the reported error.
  3. Switch 'Source' to 'Database' and select the workflow by ID to avoid inline JSON entirely.

Example fix

// before: workflowJson contains '{ "nodes": [ {' (broken)
// after: paste the full valid export, or:
source: 'database'
workflowId: { __rl: true, value: '42', mode: 'id' }
Defensive patterns

Strategy: validation

Validate before calling

const workflowJson = context.getNodeParameter('workflowJson', itemIndex) as string;
try { JSON.parse(workflowJson); }
catch (e) { throw new Error(`workflowJson invalid: ${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) { /* guide user to fix JSON */ }

Prevention

When it happens

Trigger: Hand-edited or truncated workflow JSON pasted into the node's workflowJson parameter; smart quotes or stray characters introduced during copy-paste.

Common situations: Editing the parameter manually; pasting partial exports; switching a workflow from database-linked to inline and mangling the JSON.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/73a1fb4f446db73f. Report an issue: GitHub.