{"record":{"id":"ff51fdaa280dfa5d","repo":"n8n-io/n8n","slug":"error-message-ff51fd","errorCode":null,"errorMessage":"${error.message}","messagePattern":"\\$\\{error\\.message\\}","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vendors/Moonshot/actions/router.ts","lineNumber":41,"sourceCode":"\t\t\tbreak;\n\t\tcase 'text':\n\t\t\texecute = text[moonshotTypeData.operation].execute;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new NodeOperationError(this.getNode(), `The resource \"${resource}\" is not supported!`);\n\t}\n\n\tfor (let i = 0; i < items.length; i++) {\n\t\ttry {\n\t\t\tconst responseData = await execute.call(this, i);\n\t\t\treturnData.push(...responseData);\n\t\t} catch (error) {\n\t\t\tif (this.continueOnFail()) {\n\t\t\t\treturnData.push({ json: { error: error.message }, pairedItem: { item: i } });\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthrow new NodeOperationError(this.getNode(), error, {\n\t\t\t\titemIndex: i,\n\t\t\t\tdescription: error.description,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn [returnData];\n}\n","sourceCodeStart":23,"sourceCodeEnd":50,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/Moonshot/actions/router.ts#L23-L50","documentation":"Per-item catch in the Moonshot router's execute loop. When continueOnFail is off, any error from the selected operation's execute callback is re-thrown as a NodeOperationError with the itemIndex and the original error's description; the original message is preserved.","triggerScenarios":"The Moonshot text or image operation threw for item i — typically an API error from Moonshot's Kimi endpoints (rate limit, content moderation, model unavailable, invalid parameters). With continueOnFail on, the error is captured into the item's JSON instead.","commonSituations":"One bad input item aborts the batch; continueOnFail not enabled when partial success is desired; underlying Moonshot API error propagated through the router.","solutions":["Read error.message for the underlying operation's reason.","Enable 'Continue On Fail' on the node to keep processing past the failing item.","Inspect the item at error.itemIndex and fix or remove it.","Address the root cause named in the underlying error."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-validate each item's required parameters for the chosen operation before the loop.\nfunction validateMoonshotItem(item: INodeExecutionData, resource: string, operation: string): string | null {\n  if (!item || typeof item !== 'object') return 'item is missing';\n  if (resource === 'text' && operation === 'chat' && !item.json?.prompt && !item.json?.messages) {\n    return 'text.chat requires item.json.prompt or item.json.messages';\n  }\n  return null;\n}","typeGuard":"function isItemIndexError(e: unknown): e is NodeOperationError & { itemIndex: number } {\n  return e instanceof NodeOperationError && typeof (e as { itemIndex?: number }).itemIndex === 'number';\n}","tryCatchPattern":"for (let i = 0; i < items.length; i++) {\n  try {\n    const responseData = await execute.call(this, i);\n    returnData.push(...responseData);\n  } catch (error) {\n    if (this.continueOnFail()) {\n      returnData.push({ json: { error: (error as Error).message }, pairedItem: { item: i } });\n      continue;\n    }\n    throw new NodeOperationError(this.getNode(), error, { itemIndex: i });\n  }\n}","preventionTips":["Enable 'Continue On Fail' on the node when running batches where some items may be invalid.","Pre-validate each item's required parameters for the chosen operation before the execute loop.","Log the failing itemIndex so retries can target the specific item.","Address the root-cause operation error (Moonshot API) rather than catching only at the router."],"tags":["moonshot","router","item-error","continue-on-fail"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}