n8n-io/n8n · error · Error
Guardrail "${this.name}" requires a strategy
Error message
Guardrail "${this.name}" requires a strategy What it means
Thrown by Guardrail.build() when .strategy(...) was never called. Even with a type set, the runtime needs a strategy (e.g. block/redact) to know what action to take when the guard fires.
Source
Thrown at packages/@n8n/agents/src/sdk/guardrail.ts:40
strategy(strategy: GuardrailStrategy): this {
this.strategyType = strategy;
return this;
}
detect(types: PiiDetectionType[]): this {
this.detectionTypes = types;
return this;
}
threshold(value: number): this {
this.thresholdValue = value;
return this;
}
build(): BuiltGuardrail {
if (!this.guardType) throw new Error(`Guardrail "${this.name}" requires a type`);
if (!this.strategyType) throw new Error(`Guardrail "${this.name}" requires a strategy`);
return {
name: this.name,
guardType: this.guardType,
strategy: this.strategyType,
_config: {
detectionTypes: this.detectionTypes,
threshold: this.thresholdValue,
},
};
}
}
View on GitHub (pinned to 5ac6606e81)
Solutions
- Call .strategy('block' | 'redact' | other GuardrailStrategy) before consumption.
- Validate each Guardrail with a build() in tests.
- Co-locate .type() and .strategy() in builder helpers so neither is forgotten.
Example fix
// before
const g = new Guardrail('pii-out').type('output');
// after
const g = new Guardrail('pii-out').type('output').strategy('block'); Defensive patterns
Strategy: validation
Validate before calling
function assertGuardStrategySet(g: { strategyType?: string }) {
if (!g.strategyType) throw new Error('Guardrail missing .strategy()');
} Type guard
function guardHasStrategy(g: { strategyType?: string }): g is { strategyType: string } {
return typeof g.strategyType === 'string' && g.strategyType.length > 0;
} Prevention
- Always pair .type() and .strategy() in builder helpers.
- Lint for Guardrail usages that omit either call.
When it happens
Trigger: Constructing new Guardrail('name'), calling .type(...) but not .strategy(...), then triggering build.
Common situations: Same shape as 69 — refactors, conditionals, copy-paste that lose the .strategy() call.
Related errors
- Guardrail "${this.name}" requires a type
- Eval "${this.evalName}" requires either .check() or .judge()
- Tool name is required
- Tool "${this.name}" requires a description
- Tool "${this.name}" requires an input schema
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/68ca6c2c56694abf.
Report an issue: GitHub.