{"record":{"id":"9fa309019ef1bb57","repo":"Automattic/mongoose","slug":"cannot-set-special-property-last-on-a-schema","errorCode":null,"errorMessage":"Cannot set special property `${last}` on a schema","messagePattern":"Cannot set special property `(.+?)` on a schema","errorType":"exception","errorClass":"MongooseError","httpStatus":null,"severity":"error","filePath":"lib/schema.js","lineNumber":1306,"sourceCode":"      return mapPath;\n    }\n\n    // Look if a parent of this path is mixed\n    schematype = this.hasMixedParent(cleanPath);\n    if (schematype != null) {\n      return schematype;\n    }\n\n    // subpaths?\n    return hasNumericSubpathRegex.test(path)\n      ? getPositionalPath(this, path, cleanPath)\n      : undefined;\n  }\n\n  const subpaths = path.indexOf('.') === -1 ? [path] : path.split('.');\n  const last = subpaths.pop();\n  if (utils.specialProperties.has(last)) {\n    throw new MongooseError('Cannot set special property `' + last + '` on a schema');\n  }\n\n  // some path names conflict with document methods\n  const firstPieceOfPath = subpaths.length === 0 ? last : subpaths[0];\n  if (Object.hasOwn(reserved, firstPieceOfPath) && !this.options.suppressReservedKeysWarning) {\n    const errorMessage = `\\`${firstPieceOfPath}\\` is a reserved schema pathname and may break some functionality. ` +\n      'You are allowed to use it, but use at your own risk. ' +\n      'To disable this warning pass `suppressReservedKeysWarning` as a schema option.';\n\n    utils.warn(errorMessage);\n  }\n\n  if (typeof obj === 'object' && utils.hasUserDefinedProperty(obj, 'ref')) {\n    validateRef(obj.ref, path);\n  }\n\n  // update the tree\n  let branch = this.tree;","sourceCodeStart":1288,"sourceCodeEnd":1324,"githubUrl":"https://github.com/Automattic/mongoose/blob/49cdab01366679723b487ecb754b38570f783289/lib/schema.js#L1288-L1324","documentation":"Error \"Cannot set special property `${last}` on a schema\" thrown in Automattic/mongoose.","triggerScenarios":"Thrown at lib/schema.js:1306 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"}