n8n-io/n8n · error · NodeOperationError

${error.message}

Error message

${error.message}

What it means

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.

Source

Thrown at packages/@n8n/nodes-langchain/nodes/vendors/Moonshot/actions/router.ts:41

			break;
		case 'text':
			execute = text[moonshotTypeData.operation].execute;
			break;
		default:
			throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not supported!`);
	}

	for (let i = 0; i < items.length; i++) {
		try {
			const responseData = await execute.call(this, i);
			returnData.push(...responseData);
		} catch (error) {
			if (this.continueOnFail()) {
				returnData.push({ json: { error: error.message }, pairedItem: { item: i } });
				continue;
			}

			throw new NodeOperationError(this.getNode(), error, {
				itemIndex: i,
				description: error.description,
			});
		}
	}

	return [returnData];
}

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Read error.message for the underlying operation's reason.
  2. Enable 'Continue On Fail' on the node to keep processing past the failing item.
  3. Inspect the item at error.itemIndex and fix or remove it.
  4. Address the root cause named in the underlying error.
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-validate each item's required parameters for the chosen operation before the loop.
function validateMoonshotItem(item: INodeExecutionData, resource: string, operation: string): string | null {
  if (!item || typeof item !== 'object') return 'item is missing';
  if (resource === 'text' && operation === 'chat' && !item.json?.prompt && !item.json?.messages) {
    return 'text.chat requires item.json.prompt or item.json.messages';
  }
  return null;
}

Type guard

function isItemIndexError(e: unknown): e is NodeOperationError & { itemIndex: number } {
  return e instanceof NodeOperationError && typeof (e as { itemIndex?: number }).itemIndex === 'number';
}

Try / catch

for (let i = 0; i < items.length; i++) {
  try {
    const responseData = await execute.call(this, i);
    returnData.push(...responseData);
  } catch (error) {
    if (this.continueOnFail()) {
      returnData.push({ json: { error: (error as Error).message }, pairedItem: { item: i } });
      continue;
    }
    throw new NodeOperationError(this.getNode(), error, { itemIndex: i });
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: One bad input item aborts the batch; continueOnFail not enabled when partial success is desired; underlying Moonshot API error propagated through the router.

Related errors


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