Errors
Every error answers with a JSON ErrorDescription body and three headers:
| Header | Content |
|---|---|
x-error-code | the error code (below, or the error code of the database) |
x-error-message | a short message |
x-error-additional-info | details, e.g. why a filter could not be parsed |
Unknown routes answer 404 in the same form, with CORS headers.
Error codes of the server
| Code | Status | Meaning |
|---|---|---|
4001 | 400 | A value that could not be decoded (body, query parameter, filter) |
4002 | 400 | Empty batch (e.g. insert many with an empty list) |
4003 | 400 | Empty filter on update/delete many without matchAll=true |
4004 | 400 | Filter in the body and as a query parameter |
4005 | 400 | Aggregation filter in front of a stage that must come first |
4006 | 400 | Invalid index key |
4007 | 400 | Invalid collection name |
4008 | — | Import line that is not a document (in the import answer) |
4009 | 400 | Invalid collection options |
4010 | 400 | A document that is not valid: refused by the schema of a declared collection or by a before-hook (MongocampError.validation); the fields are in issues |
4011 | 401 / 403 | User not authorized: 401 for a missing or invalid token, 403 for a missing grant (AUTH_GRANT_DENIED_STATUS) |
4012 | 401 / 403 | User not authorized for another user |
4013 | 401 | The user is disabled (3.0): a login with the right password, Basic auth, the api key; a token issued before answers 4011 (revoked) |
4014 | 401 | A refresh token that was used before: the session is revoked (3.0) |
4031 | 403 | Denied aggregation operator |
4032 | 403 | Aggregation reads a collection without the grant, or another database |
4033 | 403 | An access rule or a field rule of a declared collection refuses the request (2.10.0) |
4035 | 403 | Login with an unverified e-mail address (AUTH_REQUIRE_VERIFIED_EMAIL, 3.0) |
4041 | 404 | Job not found |
4042 | 404 | Job class (handler) not found |
4091 | 409 | Collection (target) exists |
4093 | 409 | Another user has this e-mail address or linked identity (3.0) |
4094 | 409 | A queued job is running and cannot be deleted (DELETE /system/queue/{id}, 3.1.0) |
4092 | 409 | A write based on an outdated version (versioned); current holds the stored document, in the extendedJson mode of the request (2.6) |
4121 | 412 | Job already added |
4131 | 413 | The body is greater than BODY_MAX_BYTES (2.6) |
4132 | 413 | The uploaded file is greater than GRIDFS_UPLOAD_MAX_BYTES (2.6) |
4133 | 413 | The import is greater than IMPORT_MAX_BYTES (2.6) |
4281 | 428 | A versioned collection with required: true got a write without version |
4401, 4402 | 400 | Bad insert request, id missing for replace |
4403 | 400 | A token of an auth flow (verification, reset, invitation, magic link) that is used, expired or unknown (3.0) |
5011 | 501 | Live updates need a replica set or a sharded cluster |
5031 | 503 | Image variants are busy (at most 4 render at once), Retry-After: 1 (3.0) |
Errors of the database
A request that the database refuses because of its content gets the status that fits. The code is the database error code:
| Status | Cases |
|---|---|
400 | an invalid pipeline, an empty field name in sort or projection, an index without keys, dropping _id_, a validator refusing a document (code 121, with issues), a change of _id (code 66) |
404 | an index or collection that does not exist |
409 | a duplicate key, also when a unique index is created over duplicate data, or a conflicting index |
500 | everything else, e.g. a lost connection |
Messages do not contain the database, the collection or duplicate values: E11000 duplicate key error collection: shop.customers index: email_1 dup key: { email: "a@b.c" } is answered as E11000 duplicate key error, index: email_1.
Invalid documents
Since 2.3 a document that is not valid is answered with 400 and its fields in issues, whether the schema of a declared collection (code 4010), a before-hook or the validator of the collection in MongoDB (code 121) refuses it:
{
"code": 121,
"msg": "Document failed validation",
"additionalInfo": "",
"issues": [
{ "path": "items.1.sku", "message": "is required" },
{ "path": "qty", "message": "minimum: comparison failed (expected minimum 1)" }
]
}path is in dot notation, empty for the whole document. A request with several documents starts the path with the position ([3].qty), an import with the line number. The values that were refused are never part of the answer. Other errors have no issues.
Missing resources
A missing resource is 404. This covers indexes, configurations, collections (info, fields, schema, index stats, drop, clear), buckets, files, single documents (delete, patch), databases, users, roles and jobs. The many/* routes answer with their counts.
GET /mongodb/databases/{db}/collections for a database that does not exist is 404 for administrators and [] for everyone else, so other users cannot find out which databases exist.
