mongodb
config_error
ai_generated
true
MongoServerError: shard key not found in document
ID: mongodb/shard-key-violation
80%Fix Rate
84%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 7 | active | — | — | — |
Root Cause
Document missing required shard key field.
genericWorkarounds
-
90% success Ensure all documents include shard key field before insert
-
88% success Validate documents client-side before write operations
Dead Ends
Common approaches that don't work:
-
Change shard key on existing collection
75% fail
Requires resharding, very expensive
-
Insert null shard key values
82% fail
All null docs route to one shard, hotspot