{"record":{"id":"da8db23bffe2a4f3","repo":"Automattic/mongoose","slug":"mongoose-da8db2","errorCode":"MONGOOSE","errorMessage":"mongoose: To create a new ObjectId please try `Mongoose.Types.ObjectId` instead of using `Mongoose.Schema.Types.ObjectId`. Set the `suppressWarning` option if you're trying to create a hex char path in your schema.","messagePattern":"mongoose: To create a new ObjectId please try `Mongoose\\.Types\\.ObjectId` instead of using `Mongoose\\.Schema\\.Types\\.ObjectId`\\. Set the `suppressWarning` option if you're trying to create a hex char path in your schema\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/schema/objectId.js","lineNumber":33,"sourceCode":"const CastError = SchemaType.CastError;\nlet Document;\n\n/**\n * ObjectId SchemaType constructor.\n *\n * @param {string} key\n * @param {object} options\n * @param {object} schemaOptions\n * @param {Schema} parentSchema\n * @inherits SchemaType\n * @api public\n */\n\nfunction SchemaObjectId(key, options, _schemaOptions, parentSchema) {\n  const isKeyHexStr = typeof key === 'string' && key.length === 24 && /^[a-f0-9]+$/i.test(key);\n  const suppressWarning = options?.suppressWarning;\n  if ((isKeyHexStr || typeof key === 'undefined') && !suppressWarning) {\n    utils.warn('mongoose: To create a new ObjectId please try ' +\n      '`Mongoose.Types.ObjectId` instead of using ' +\n      '`Mongoose.Schema.Types.ObjectId`. Set the `suppressWarning` option if ' +\n      'you\\'re trying to create a hex char path in your schema.');\n  }\n  SchemaType.call(this, key, options, 'ObjectId', parentSchema);\n}\n\n/**\n * This schema type's name, to defend against minifiers that mangle\n * function names.\n *\n * @api public\n */\nSchemaObjectId.schemaName = 'ObjectId';\n\nSchemaObjectId.defaultOptions = {};\n\n/*!","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/Automattic/mongoose/blob/49cdab01366679723b487ecb754b38570f783289/lib/schema/objectId.js#L15-L51","documentation":"Error \"mongoose: To create a new ObjectId please try `Mongoose.Types.ObjectId` instead of using `Mongoose.Schema.Types.ObjectId`. Set the `suppressWarning` option if you're trying to create a hex char path in your schema.\" thrown in Automattic/mongoose.","triggerScenarios":"Thrown at lib/schema/objectId.js:33 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-22T04:17:13.399Z"}