n8n-io/n8n · error · ExpressionExtensionError

isOdd() is only callable on integers

Error message

isOdd() is only callable on integers

What it means

`isOdd(value)` mirrors `isEven`: it requires `Number.isInteger(value)`. Non-integers (including NaN and Infinity) throw. Note the body uses `Math.abs(value) % 2 === 1` so the integer check is mandatory before the modulo.

Source

Thrown at packages/@n8n/expression-runtime/src/extensions/number-extensions.ts:32

	];

	try {
		return value.toLocaleString(locales as string, config);
	} catch {
		return String(value);
	}
}

function isEven(value: number) {
	if (!Number.isInteger(value)) {
		throw new ExpressionExtensionError('isEven() is only callable on integers');
	}
	return value % 2 === 0;
}

function isOdd(value: number) {
	if (!Number.isInteger(value)) {
		throw new ExpressionExtensionError('isOdd() is only callable on integers');
	}
	return Math.abs(value) % 2 === 1;
}

function floor(value: number) {
	return Math.floor(value);
}

function ceil(value: number) {
	return Math.ceil(value);
}

function abs(value: number) {
	return Math.abs(value);
}

function isInteger(value: number) {
	return Number.isInteger(value);

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Round first: `.floor().isOdd()` or `.toInt().isOdd()`.
  2. Validate integrality upstream before the expression runs.
  3. Re-check the upstream node's output type.

Example fix

// before
{{ $json.score.isOdd() }}
// after
{{ $json.score.floor().isOdd() }}
Defensive patterns

Strategy: type-guard

Validate before calling

if (!Number.isInteger($json.n)) {
  throw new Error('isOdd(): value must be an integer, got ' + $json.n);
}
return $json;

Type guard

const isInteger = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v);

Prevention

When it happens

Trigger: `.isOdd()` on `2.7`, on `NaN`, or on a value that arrived as a float from upstream.

Common situations: Fractional result from a prior computation; a parsed float where an integer was expected; rounding was skipped.

Related errors


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