n8n-io/n8n · error · GuardrailError
Guardrail validation failed: ${error instanceof Error ? erro
Error message
Guardrail validation failed: ${error instanceof Error ? error.message : 'Unknown error'} What it means
Catch-all GuardrailError thrown by the Guardrails model helper for any error during LLM guardrail validation that is not a LangChain parser error. The message is 'Guardrail validation failed: ' plus the underlying error.message (or 'Unknown error' for non-Error throws). It is the fall-through branch after the parser-error check.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/Guardrails/helpers/model.ts:126
return content[0].text as string;
}
throw new Error('Invalid content type');
};
const text = extractText(result.content);
const { confidenceScore, flagged } = await outputParser.parse(text);
// Validate output consistency
if (typeof confidenceScore !== 'number' || typeof flagged !== 'boolean') {
throw new GuardrailError(name, 'Invalid output format', 'Expected number and boolean fields');
}
return { confidenceScore, flagged };
} catch (error) {
if (isLangChainParserError(error)) {
throw new GuardrailError(name, 'Failed to parse output', MODEL_OUTPUT_PARSER_ERROR_MESSAGE);
}
throw new GuardrailError(
name,
`Guardrail validation failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
error?.description,
);
}
}
export async function runLLMValidation(
name: string,
inputText: string,
{ model, prompt, threshold, systemMessage }: LLMConfig,
): Promise<GuardrailResult> {
try {
const result = await runLLM(name, model, prompt, inputText, systemMessage);
const triggered = result.flagged && result.confidenceScore >= threshold;
return {
guardrailName: name,
tripwireTriggered: triggered,View on GitHub (pinned to 5ac6606e81)
Solutions
- Read the appended error.message to distinguish auth/network/rate-limit causes.
- For rate limits, add backoff/retry at the model client or workflow level.
- Verify the model credentials and endpoint configuration in the connected Chat Model node.
- Wrap the guardrail in retry logic and fail closed only after retries are exhausted.
Defensive patterns
Strategy: retry
Type guard
function isGuardrailValidationFailure(e) {
return e instanceof GuardrailError && e.message.startsWith('Guardrail validation failed:');
} Try / catch
try { ... } catch (e) {
if (e instanceof GuardrailError && e.message.startsWith('Guardrail validation failed:')) {
// inspect e.message suffix for auth/rate-limit/network; retry or fail-closed
} else throw e;
} Prevention
- Verify model credentials and endpoint before relying on LLM guardrails.
- Add backoff/retry around model calls for transient failures.
- Log the appended message to classify the underlying cause.
When it happens
Trigger: Inside the try block around model.invoke/parse, any thrown error that is not an OutputParserException reaches the second throw branch: model API failures, network errors, auth errors, unexpected exceptions from the model client, or non-Error rejections.
Common situations: Model provider rate limit or 401 auth error; network timeout reaching the LLM endpoint; langchain model client bug; a custom model client that throws plain objects; revoked API credentials.
Related errors
- error?.description || error?.message
- error?.description || error?.message || 'Unknown error'
- Invalid output format
- Failed to parse output
- Error executing tool: ${(error as Error).message}
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/985c70076f200207.
Report an issue: GitHub.