{"record":{"id":"84b8fcc31c58cd58","repo":"n8n-io/n8n","slug":"provided-limit-value-is-not-a-number-please-pro","errorCode":null,"errorMessage":"Provided \"limit\" value is not a number. Please provide a numeric value.","messagePattern":"Provided \"limit\" value is not a number\\. Please provide a numeric value\\.","errorType":"exception","errorClass":"TypeORMError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/typeorm/src/query-builder/SelectQueryBuilder.ts","lineNumber":1333,"sourceCode":"\n\t\tif (nulls) {\n\t\t\tthis.expressionMap.orderBys[sort] = { order, nulls };\n\t\t} else {\n\t\t\tthis.expressionMap.orderBys[sort] = order;\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets LIMIT - maximum number of rows to be selected.\n\t * NOTE that it may not work as you expect if you are using joins.\n\t * If you want to implement pagination, and you are having join in your query,\n\t * then use the take method instead.\n\t */\n\tlimit(limit?: number): this {\n\t\tthis.expressionMap.limit = this.normalizeNumber(limit);\n\t\tif (this.expressionMap.limit !== undefined && isNaN(this.expressionMap.limit))\n\t\t\tthrow new TypeORMError(\n\t\t\t\t`Provided \"limit\" value is not a number. Please provide a numeric value.`,\n\t\t\t);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets OFFSET - selection offset.\n\t * NOTE that it may not work as you expect if you are using joins.\n\t * If you want to implement pagination, and you are having join in your query,\n\t * then use the skip method instead.\n\t */\n\toffset(offset?: number): this {\n\t\tthis.expressionMap.offset = this.normalizeNumber(offset);\n\t\tif (this.expressionMap.offset !== undefined && isNaN(this.expressionMap.offset))\n\t\t\tthrow new TypeORMError(\n\t\t\t\t`Provided \"offset\" value is not a number. Please provide a numeric value.`,\n\t\t\t);","sourceCodeStart":1315,"sourceCodeEnd":1351,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/typeorm/src/query-builder/SelectQueryBuilder.ts#L1315-L1351","documentation":"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.","triggerScenarios":"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().","commonSituations":"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.","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."],"exampleFix":"// before\nqb.limit(req.query.limit); // string from query\n// after\nconst limit = req.query.limit ? Number(req.query.limit) : undefined;\nif (limit !== undefined && !Number.isFinite(limit)) throw new Error('limit must be numeric');\nqb.limit(limit);","handlingStrategy":"validation","validationCode":"function toFiniteNumber(value: unknown, max?: number): number | undefined {\n  if (value == null || value === '') return undefined;\n  const n = Number(value);\n  if (!Number.isFinite(n)) throw new Error(`Expected a numeric limit, got: ${String(value)}`);\n  if (n < 0) throw new Error('limit must be non-negative');\n  return max !== undefined ? Math.min(n, max) : n;\n}\n// then: qb.limit(toFiniteNumber(req.query.limit, 1000));","typeGuard":"function isFiniteNumber(v: unknown): v is number {\n  return typeof v === 'number' && Number.isFinite(v);\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["typeorm","query-builder","validation","pagination"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}