n8n-io/n8n · error · TypeORMError

Provided "offset" value is not a number. Please provide a nu

Error message

Provided "offset" value is not a number. Please provide a numeric value.

What it means

Thrown by SelectQueryBuilder.offset when the normalized value is NaN. Identical mechanism to limit(): a string that Number() cannot parse becomes NaN, and the guard rejects it before it reaches the SQL layer.

Source

Thrown at packages/@n8n/typeorm/src/query-builder/SelectQueryBuilder.ts:1349

		this.expressionMap.limit = this.normalizeNumber(limit);
		if (this.expressionMap.limit !== undefined && isNaN(this.expressionMap.limit))
			throw new TypeORMError(
				`Provided "limit" value is not a number. Please provide a numeric value.`,
			);

		return this;
	}

	/**
	 * Sets OFFSET - selection offset.
	 * NOTE that it may not work as you expect if you are using joins.
	 * If you want to implement pagination, and you are having join in your query,
	 * then use the skip method instead.
	 */
	offset(offset?: number): this {
		this.expressionMap.offset = this.normalizeNumber(offset);
		if (this.expressionMap.offset !== undefined && isNaN(this.expressionMap.offset))
			throw new TypeORMError(
				`Provided "offset" value is not a number. Please provide a numeric value.`,
			);

		return this;
	}

	/**
	 * Sets maximal number of entities to take.
	 */
	take(take?: number): this {
		this.expressionMap.take = this.normalizeNumber(take);
		if (this.expressionMap.take !== undefined && isNaN(this.expressionMap.take))
			throw new TypeORMError(
				`Provided "take" value is not a number. Please provide a numeric value.`,
			);

		return this;
	}

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Compute offset from parsed numbers: `const offset = (Number(page) - 1) * Number(size)`.
  2. Guard: `if (!Number.isFinite(offset)) throw ...` before `.offset()`.
  3. Pass undefined when no offset is needed rather than ''.

Example fix

// before
qb.offset(`${(req.query.page - 1) * 10}`); // page is string, math is wrong
// after
const page = Number(req.query.page) || 1;
qb.offset((page - 1) * 10);
Defensive patterns

Strategy: validation

Validate before calling

function toOffset(value: unknown): number | undefined {
  if (value == null || value === '') return undefined;
  const n = Number(value);
  if (!Number.isFinite(n) || n < 0) throw new Error(`Invalid offset: ${String(value)}`);
  return Math.trunc(n);
}
// then: qb.offset(toOffset(req.query.offset));

Type guard

function isNonNegativeInt(v: unknown): v is number {
  return typeof v === 'number' && Number.isInteger(v) && v >= 0;
}

Prevention

When it happens

Trigger: `.offset('abc')`, `.offset('5-10')`, `.offset(' ')`, or passing a page-index math expression as a string like `.offset((page-1) * size)` where one operand is a string causing concatenation.

Common situations: Pagination helpers that mix string query params with arithmetic without casting; off-by-one where offset is computed as `page * size` but page is the string '2' producing '2size'.

Related errors


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