UUID caster called out of scope, and missing schema path ino. #15202
Labels
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
Milestone
Prerequisites
Mongoose version
8.9.5
Node.js version
20.5
MongoDB server version
6
Typescript version (if applicable)
No response
Description
./lib/schema/uuid.js line~112
if this throws, there is no (this) path, so the validation error reason ends up looking like:
"reason: TypeError: Cannot read properties of undefined (reading 'path')"
Steps to Reproduce
import mongoose, { Schema } from 'mongoose'
const Example = mongoose.model('example', new Schema({
uuid: 'UUID'
}))
const doc = new Example({
uuid: '11111111-1111-1111-1111-111111111111'
})
doc.save()
// error reason reads reason: TypeError: Cannot read properties of undefined (reading 'path')
Expected Behavior
reason: CastError: Cast to UUID failed for value "11111111-1111-1111-1111-111111111111" (type string) at path "uuid"
The text was updated successfully, but these errors were encountered: