Automattic/mongoose · error · TypeError
Invalid value for schema path `${fullPath}`, got value "${va
Error message
Invalid value for schema path `${fullPath}`, got value "${val}" What it means
Error "Invalid value for schema path `${fullPath}`, got value "${val}"" thrown in Automattic/mongoose.
Source
Thrown at lib/schema.js:811
prefix = prefix || '';
// avoid prototype pollution
if (prefix === '__proto__.' || prefix === 'constructor.' || prefix === 'prototype.') {
return this;
}
const keys = Object.keys(obj);
const typeKey = this.options.typeKey;
for (const key of keys) {
if (utils.specialProperties.has(key)) {
continue;
}
const fullPath = prefix + key;
const val = obj[key];
if (val == null) {
throw new TypeError('Invalid value for schema path `' + fullPath +
'`, got value "' + val + '"');
}
// Retain `_id: false` but don't set it as a path, re: gh-8274.
if (key === '_id' && val === false) {
continue;
}
// Deprecate setting schema paths to primitive types (gh-7558)
let isMongooseTypeString = false;
if (typeof val === 'string') {
// Handle the case in which the type is specified as a string (eg. 'date', 'oid', ...)
const MongooseTypes = this.base?.Schema.Types ?? Schema.Types;
const upperVal = val.charAt(0).toUpperCase() + val.substring(1);
isMongooseTypeString = MongooseTypes[upperVal] != null;
}
if (
key !== '_id' &&
((typeof val !== 'object' && typeof val !== 'function' && !isMongooseTypeString) ||
val == null)View on GitHub (pinned to 49cdab0136)
When it happens
Trigger: Thrown at lib/schema.js:811 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/21a09504b5a9d177.
Report an issue: GitHub.