n8n-io/n8n · error · TypeORMError
Provided "limit" value is not a number. Please provide a num
Error message
Provided "limit" value is not a number. Please provide a numeric value.
What it means
Thrown by SelectQueryBuilder.limit when the value, after normalizeNumber, is not undefined yet isNaN. normalizeNumber returns the input as-is for real numbers/undefined/null, otherwise coerces via Number(); any non-numeric string becomes NaN and trips the guard.
Source
Thrown at packages/@n8n/typeorm/src/query-builder/SelectQueryBuilder.ts:1333
if (nulls) {
this.expressionMap.orderBys[sort] = { order, nulls };
} else {
this.expressionMap.orderBys[sort] = order;
}
return this;
}
/**
* Sets LIMIT - maximum number of rows to be selected.
* 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 take method instead.
*/
limit(limit?: number): this {
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.`,
);View on GitHub (pinned to 5ac6606e81)
Solutions
- Coerce before calling: `qb.limit(Number(value))` and gate on `!Number.isFinite(Number(value))`.
- Validate input: if (typeof value === 'string' && !/^\d+$/.test(value)) reject early.
- Pass undefined instead of an empty string when no limit is intended.
Example fix
// before
qb.limit(req.query.limit); // string from query
// after
const limit = req.query.limit ? Number(req.query.limit) : undefined;
if (limit !== undefined && !Number.isFinite(limit)) throw new Error('limit must be numeric');
qb.limit(limit); Defensive patterns
Strategy: validation
Validate before calling
function toFiniteNumber(value: unknown, max?: number): number | undefined {
if (value == null || value === '') return undefined;
const n = Number(value);
if (!Number.isFinite(n)) throw new Error(`Expected a numeric limit, got: ${String(value)}`);
if (n < 0) throw new Error('limit must be non-negative');
return max !== undefined ? Math.min(n, max) : n;
}
// then: qb.limit(toFiniteNumber(req.query.limit, 1000)); Type guard
function isFiniteNumber(v: unknown): v is number {
return typeof v === 'number' && Number.isFinite(v);
} Prevention
- Parse query/env strings to numbers once at the request boundary.
- Cap page sizes to a sane maximum to protect the database.
- Treat empty strings as undefined rather than forwarding them.
When it happens
Trigger: Calling `.limit('abc')`, `.limit('')`, `.limit('10abc')`, or passing a query-string/CLI value typed as string that is not purely numeric. Passing an object or array also yields NaN after Number().
Common situations: Reading `limit` from `req.query` (always a string) and forgetting to parse; passing a user-typed page-size config that is empty or contains units ('10 rows'); default-value bugs where undefined chains into a string fallback.
Related errors
- Provided "offset" value is not a number. Please provide a nu
- Provided "take" value is not a number. Please provide a nume
- Provided "skip" value is not a number. Please provide a nume
- Could not find any entity of type "${target}" matching: ${cr
- Property "${propertyPath}" was not found in "${metadata.targ
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/84b8fcc31c58cd58.
Report an issue: GitHub.