{"record":{"id":"d740b2465ae7f504","repo":"Automattic/mongoose","slug":"cast-to-number-failed-for-value-stringvalue-ty","errorCode":null,"errorMessage":"Cast to Number failed for value ${stringValue} (type ${valueType}) at path \"limit\"","messagePattern":"Cast to Number failed for value (.+?) \\(type (.+?)\\) at path \"limit\"","errorType":"exception","errorClass":"CastError","httpStatus":null,"severity":"error","filePath":"lib/query.js","lineNumber":939,"sourceCode":" * #### Note:\n *\n * Cannot be used with `distinct()`\n *\n * @method limit\n * @memberOf Query\n * @instance\n * @param {number} val\n * @api public\n */\n\nQuery.prototype.limit = function limit(v) {\n  this._validate('limit');\n\n  if (typeof v === 'string') {\n    try {\n      v = castNumber(v);\n    } catch {\n      throw new CastError('Number', v, 'limit');\n    }\n  }\n\n  this.options.limit = v;\n  return this;\n};\n\n/**\n * Specifies the number of documents to skip.\n *\n * #### Example:\n *\n *     query.skip(100).limit(20);\n *\n * #### Note:\n *\n * Cannot be used with `distinct()`\n *","sourceCodeStart":921,"sourceCodeEnd":957,"githubUrl":"https://github.com/Automattic/mongoose/blob/49cdab01366679723b487ecb754b38570f783289/lib/query.js#L921-L957","documentation":"Error \"Cast to Number failed for value ${stringValue} (type ${valueType}) at path \"limit\"\" thrown in Automattic/mongoose.","triggerScenarios":"Thrown at lib/query.js:939 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49cdab01366679723b487ecb754b38570f783289","analyzedAt":"2026-08-21T22:54:00.882Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}