{"record":{"id":"ee4d1c000d27d4a9","repo":"n8n-io/n8n","slug":"metadata-is-required","errorCode":null,"errorMessage":"Metadata is required","messagePattern":"Metadata is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v2/actions/conversation/update.operation.ts","lineNumber":43,"sourceCode":"const displayOptions = {\n\tshow: {\n\t\toperation: ['update'],\n\t\tresource: ['conversation'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst conversationId = this.getNodeParameter('conversationId', i, '') as string;\n\tconst metadata = this.getNodeParameter('metadata', i, '') as string;\n\n\tif (!conversationId) {\n\t\tthrow new Error('Conversation ID is required');\n\t}\n\n\tif (!metadata) {\n\t\tthrow new Error('Metadata is required');\n\t}\n\n\tconst body: IDataObject = {};\n\n\tbody.metadata = jsonParse(metadata, {\n\t\terrorMessage: 'Invalid JSON in metadata field',\n\t});\n\n\tconst response = await apiRequest.call(this, 'POST', `/conversations/${conversationId}`, {\n\t\tbody,\n\t});\n\n\treturn [\n\t\t{\n\t\t\tjson: response,\n\t\t\tpairedItem: { item: i },\n\t\t},\n\t];","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v2/actions/conversation/update.operation.ts#L25-L61","documentation":"The v2 Conversation Update operation reads the metadata parameter with a default of ''. If the value is falsy (empty string), it throws a raw Error. Like error 897, this should be a NodeOperationError or UserError per n8n conventions. The metadata is required because the PATCH endpoint needs at least one field to update. The metadata is later parsed as JSON via jsonParse.","triggerScenarios":"The 'metadata' parameter is empty or not provided when updating a conversation. Since metadata is the only updatable field for conversations, an empty value means there is nothing to update.","commonSituations":"Metadata field left empty; expression {{$json[\"meta\"]}} resolves to empty; user didn't realize metadata is required for the update operation.","solutions":["Provide a valid JSON string in the metadata field (e.g. '{\"key\": \"value\"}')","If metadata comes from upstream, ensure the source field is populated and is valid JSON","If you don't need to update metadata, consider a different operation"],"exampleFix":"// before — metadata: ''\n// after  — metadata: '{\"status\": \"resolved\", \"priority\": \"high\"}'","handlingStrategy":"validation","validationCode":"const metadata = this.getNodeParameter('metadata', i, '') as string;\nif (!metadata || !metadata.trim()) {\n  throw new UserError('Metadata is required to update a conversation.');\n}\n// Also validate it's valid JSON\ntry {\n  JSON.parse(metadata);\n} catch {\n  throw new UserError('Metadata must be valid JSON.');\n}","typeGuard":"function isValidJsonString(value: string): boolean {\n  try { JSON.parse(value); return true; } catch { return false; }\n}","tryCatchPattern":null,"preventionTips":["Always provide metadata as a valid JSON string","Use a Code node to build metadata JSON from upstream fields","Validate JSON.parse succeeds before this node if metadata comes from expressions"],"tags":["openai","conversation","missing-metadata","validation","v2"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}