Automattic/mongoose · error · CastError
Cast to Number failed for value ${stringValue} (type ${value
Error message
Cast to Number failed for value ${stringValue} (type ${valueType}) at path "limit" What it means
Error "Cast to Number failed for value ${stringValue} (type ${valueType}) at path "limit"" thrown in Automattic/mongoose.
Source
Thrown at lib/query.js:939
* #### Note:
*
* Cannot be used with `distinct()`
*
* @method limit
* @memberOf Query
* @instance
* @param {number} val
* @api public
*/
Query.prototype.limit = function limit(v) {
this._validate('limit');
if (typeof v === 'string') {
try {
v = castNumber(v);
} catch {
throw new CastError('Number', v, 'limit');
}
}
this.options.limit = v;
return this;
};
/**
* Specifies the number of documents to skip.
*
* #### Example:
*
* query.skip(100).limit(20);
*
* #### Note:
*
* Cannot be used with `distinct()`
*View on GitHub (pinned to 49cdab0136)
When it happens
Trigger: Thrown at lib/query.js:939 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Automattic/mongoose@49cdab0136 (2026-08-21).
Data as JSON: /api/errors/d740b2465ae7f504.
Report an issue: GitHub.