{"record":{"id":"409dbe82364a83ad","repo":"n8n-io/n8n","slug":"error-during-parsing-of-json-schema-error-409dbe","errorCode":null,"errorMessage":"Error during parsing of JSON Schema. \n ${error}","messagePattern":"Error during parsing of JSON Schema\\. \n (.+?)","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/v1/ToolWorkflowV1.node.ts","lineNumber":229,"sourceCode":"\t\t\t\t// We initialize these even though one of them will always be empty\n\t\t\t\t// it makes it easier to navigate the ternary operator\n\t\t\t\tconst jsonExample = this.getNodeParameter('jsonSchemaExample', itemIndex, '') as string;\n\t\t\t\tconst inputSchema = this.getNodeParameter('inputSchema', itemIndex, '') as string;\n\n\t\t\t\tconst schemaType = this.getNodeParameter('schemaType', itemIndex) as 'fromJson' | 'manual';\n\t\t\t\tconst jsonSchema =\n\t\t\t\t\tschemaType === 'fromJson'\n\t\t\t\t\t\t? generateSchemaFromExample(jsonExample)\n\t\t\t\t\t\t: jsonParse<JSONSchema7>(inputSchema);\n\n\t\t\t\tconst zodSchema = convertJsonSchemaToZod<DynamicZodObject>(jsonSchema);\n\n\t\t\t\ttool = new DynamicStructuredTool({\n\t\t\t\t\tschema: zodSchema,\n\t\t\t\t\t...functionBase,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t'Error during parsing of JSON Schema. \\n ' + error,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\ttool = new DynamicTool(functionBase);\n\t\t}\n\n\t\treturn {\n\t\t\tresponse: tool,\n\t\t};\n\t}\n}\n","sourceCodeStart":211,"sourceCodeEnd":243,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/v1/ToolWorkflowV1.node.ts#L211-L243","documentation":"Thrown by the Call Workflow Tool v1 in supplyData when 'Specify Input Schema' is on and either generateSchemaFromExample (fromJson mode) or jsonParse of the manual schema or convertJsonSchemaToZod throws. The tool cannot build the structured-tool schema, so initialization fails before any run.","triggerScenarios":"Schema Type 'From JSON' with an example that isn't valid JSON or that yields an unsupported schema; Schema Type 'Manual' with a JSON Schema that violates draft-07 (bad types, circular refs, unsupported keywords); zod conversion choking on the inferred schema.","commonSituations":"Hand-writing a JSON Schema and getting a keyword wrong; pasting an example object with trailing commas; using advanced JSON Schema features ($ref, oneOf-of-mixed-types) the converter doesn't support.","solutions":["If using 'From JSON', paste a clean, parseable JSON example (validate it in a linter).","If using 'Manual', validate the JSON Schema against draft-07 and simplify unsupported constructs.","Remove $ref / complex compositions and inline the definitions.","Turn off 'Specify Input Schema' to fall back to an unstructured DynamicTool."],"exampleFix":"// before: jsonSchemaExample = \"{ name: 'x', }\" (unquoted keys, trailing comma) → throws\n// after:\njsonSchemaExample = '{\"name\":\"x\",\"age\":30}'\n// or disable 'Specify Input Schema' to skip schema parsing.","handlingStrategy":"try-catch","validationCode":"const example = this.getNodeParameter('jsonSchemaExample', itemIndex, '') as string;\nif (schemaType === 'fromJson' && example) {\n  try { JSON.parse(example); } catch (e) { throw new Error(`Example JSON invalid: ${e.message}`); }\n}","typeGuard":"function isValidJsonSchema(s: string): boolean {\n  try { const o = JSON.parse(s); return typeof o === 'object' && o !== null; } catch { return false; }\n}","tryCatchPattern":"try { zodSchema = convertJsonSchemaToZod(jsonSchema); }\ncatch (e) { /* fall back to unstructured DynamicTool */ }","preventionTips":["Validate example/schema JSON in a linter before enabling 'Specify Input Schema'.","Avoid advanced JSON Schema constructs ($ref, mixed-type oneOf) the converter doesn't support.","Disable schema specification when not strictly needed."],"tags":["workflow-tool","json-schema","zod","ai-tool","configuration"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}