{"record":{"id":"43a946b70065e41b","repo":"n8n-io/n8n","slug":"openai-structured-output-schema-invalid","errorCode":"OPENAI_STRUCTURED_OUTPUT_SCHEMA_INVALID","errorMessage":"OpenAI node output format is \"JSON Schema\", but the schema value is not a string. The node passes the raw value through JSON.parse and throws \"Failed to parse schema\" at runtime. Serialize the schema to a JSON string in textFormat.textOptions.schema.","messagePattern":"OpenAI node output format is \"JSON Schema\", but the schema value is not a string\\. The node passes the raw value through JSON\\.parse and throws \"Failed to parse schema\" at runtime\\. Serialize the schema to a JSON string in textFormat\\.textOptions\\.schema\\.","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/src/tools/workflows/detect-unparseable-openai-schema.ts","lineNumber":69,"sourceCode":"\t\t\t\tcode: 'OPENAI_STRUCTURED_OUTPUT_IGNORED',\n\t\t\t\tnodeName,\n\t\t\t\tmessage:\n\t\t\t\t\t'OpenAI node stores textFormat.textOptions as an ARRAY. At runtime the node reads that path as an object, ' +\n\t\t\t\t\t'so the JSON Schema output format is silently ignored and the node returns plain text. ' +\n\t\t\t\t\t'Store textOptions as a single object: textFormat: { textOptions: { type: \"json_schema\", name, schema } }.',\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst schema = resolved.options.schema;\n\t\tif (schema === undefined || schema === null) continue;\n\t\t// n8n treats a value as an expression only when its FIRST character is '='.\n\t\tif (typeof schema === 'string' && schema.startsWith('=')) continue;\n\t\tif (typeof schema === 'string' && schema.trim().length === 0) continue;\n\n\t\tif (typeof schema !== 'string') {\n\t\t\twarnings.push({\n\t\t\t\tcode: 'OPENAI_STRUCTURED_OUTPUT_SCHEMA_INVALID',\n\t\t\t\tnodeName,\n\t\t\t\tmessage:\n\t\t\t\t\t'OpenAI node output format is \"JSON Schema\", but the schema value is not a string. ' +\n\t\t\t\t\t'The node passes the raw value through JSON.parse and throws \"Failed to parse schema\" at runtime. ' +\n\t\t\t\t\t'Serialize the schema to a JSON string in textFormat.textOptions.schema.',\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(schema);\n\t\t} catch (error) {\n\t\t\twarnings.push({\n\t\t\t\tcode: 'OPENAI_STRUCTURED_OUTPUT_SCHEMA_INVALID',\n\t\t\t\tnodeName,\n\t\t\t\tmessage:\n\t\t\t\t\t'OpenAI node output format is \"JSON Schema\", but the schema string is not valid JSON ' +","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/src/tools/workflows/detect-unparseable-openai-schema.ts#L51-L87","documentation":"Error \"OpenAI node output format is \"JSON Schema\", but the schema value is not a string. The node passes the raw value through JSON.parse and throws \"Failed to parse schema\" at runtime. Serialize the schema to a JSON string in textFormat.textOptions.schema.\" thrown in n8n-io/n8n.","triggerScenarios":"Thrown at packages/@n8n/instance-ai/src/tools/workflows/detect-unparseable-openai-schema.ts:69 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}