n8n-io/n8n · error · ExpressionExtensionError
expected two arguments (value, defaultValue) for this functi
Error message
expected two arguments (value, defaultValue) for this function
What it means
`ifEmpty(value, defaultValue)` requires exactly two arguments; the body checks `arguments.length !== 2` and throws if it is not. The runtime shim cannot fall back because the whole point of the function is to supply a default.
Source
Thrown at packages/@n8n/expression-runtime/src/extensions/function-extensions.ts:51
}
return result;
};
const average = (...args: number[]) => {
return aAverage(args);
};
const not = (value: unknown): boolean => {
return !value;
};
function ifEmpty<T, V>(value: V, defaultValue: T) {
if (arguments.length !== 2) {
// DIVERGENCE from packages/workflow/src/extensions/extended-functions.ts:
// The original throws ExpressionError (from ExecutionBaseError). The runtime
// uses ExpressionExtensionError because the full ExpressionError class is not
// available in the extensions layer — only a minimal shim exists in safe-globals.
throw new ExpressionExtensionError(
'expected two arguments (value, defaultValue) for this function',
);
}
if (value === undefined || value === null || value === '') {
return defaultValue;
}
if (typeof value === 'object') {
if (Array.isArray(value) && !value.length) {
return defaultValue;
}
if (!Object.keys(value).length) {
return defaultValue;
}
}
return value;
}
ifEmpty.doc = {View on GitHub (pinned to 5ac6606e81)
Solutions
- Always pass a default value: `.ifEmpty('N/A')`.
- Double-check the expression has both operands inside the parentheses.
- If emptiness is acceptable, omit `.ifEmpty()` entirely rather than calling it half-formed.
Example fix
// before
{{ $json.note.ifEmpty() }}
// after
{{ $json.note.ifEmpty('N/A') }} Defensive patterns
Strategy: validation
Validate before calling
// Ensure both operands are present before constructing the expression:
if ($json.value === undefined || $json.fallback === undefined) {
throw new Error('ifEmpty(): both value and defaultValue are required');
}
return $json; Prevention
- Always pass a default: `.ifEmpty('N/A')`.
- Double-check both operands are inside the parentheses.
- If emptiness is acceptable, simply omit the call.
When it happens
Trigger: Calling `.ifEmpty()` with no default, or with only one argument; using `.ifEmpty` as a bare property reference instead of a call.
Common situations: Forgot to provide the fallback value; copied a pattern from a language where the default is optional; field renamed so the argument expression resolved to nothing.
Related errors
- isBetween(): expected exactly two args
- intersection(): expected array arg, e.g. .intersection([1, 2
- Unsupported unit '${String(errorUnit)}'. Supported: ${durati
- Cannot access "${name}" via expression extension due to secu
- Unknown expression function: ${functionName}
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/551c8ebab84aec62.
Report an issue: GitHub.