Mongoose: VersionError: No matching document found for id "5f..." version 3 modifiedPaths "items"
Mongoose tried to save a document whose array was changed by someone else since you loaded it (optimistic concurrency).
VersionError: No matching document found for id version modifiedPathsVersionError: No matching document found for id "5f"Mongoose VersionError No matching document foundNo matching document found for id version 3 Meaning
Arrays use a version key __v. A save that modifies arrays after the doc changed elsewhere fails. Reload the document and retry, use atomic update operators ($push, $set) with updateOne instead of load-modify-save, or disable versioning for the schema (versionKey: false) if safe.
Common causes
- Two requests modifying the same document array
- Load-modify-save race
- Stale document held in memory
- Array element order changes
- Retries replaying old versions
⚡ Quick fix
- Use
updateOne({_id}, {$push: { items: item }}) - Reload and reapply the change
- Retry on VersionError
Detailed fix by platform
Node.js
await Order.updateOne({ _id }, { $push: { items: item } });
How to diagnose
- Race — Concurrent writers?
- Update — Atomic operator possible?
- Retry — Implemented?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- ActiveRecord::StaleObjectError (optimistic locking) Rails: ActiveRecord::StaleObjectError: Attempted to update a stale object: Order
- CastError: Cast to Date/Number/Boolean failed Mongoose: CastError: Cast to date failed for value "abc" (type string) at path "createdAt"
- ConditionalCheckFailedException ConditionalCheckFailedException: The conditional request failed
Most viewed in MongoDB
- Document failed validation MongoDB: MongoServerError: Document failed validation (code 121)
- MongoParseError MongoDB: MongoParseError: Invalid scheme, expected connection string to start with "mongodb://" or "mongodb+srv://"
- bad auth : Authentication failed MongoDB: MongoServerError: bad auth : Authentication failed (code 8000 / 18)
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026