Skip to content

Errors ​

Every error answers with a JSON ErrorDescription body and three headers:

HeaderContent
x-error-codethe error code (below, or the error code of the database)
x-error-messagea short message
x-error-additional-infodetails, 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 ​

CodeStatusMeaning
4001400A value that could not be decoded (body, query parameter, filter)
4002400Empty batch (e.g. insert many with an empty list)
4003400Empty filter on update/delete many without matchAll=true
4004400Filter in the body and as a query parameter
4005400Aggregation filter in front of a stage that must come first
4006400Invalid index key
4007400Invalid collection name
4008—Import line that is not a document (in the import answer)
4009400Invalid collection options
4010400A 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
4011401 / 403User not authorized: 401 for a missing or invalid token, 403 for a missing grant (AUTH_GRANT_DENIED_STATUS)
4012401 / 403User not authorized for another user
4013401The user is disabled (3.0): a login with the right password, Basic auth, the api key; a token issued before answers 4011 (revoked)
4014401A refresh token that was used before: the session is revoked (3.0)
4031403Denied aggregation operator
4032403Aggregation reads a collection without the grant, or another database
4033403An access rule or a field rule of a declared collection refuses the request (2.10.0)
4035403Login with an unverified e-mail address (AUTH_REQUIRE_VERIFIED_EMAIL, 3.0)
4041404Job not found
4042404Job class (handler) not found
4091409Collection (target) exists
4093409Another user has this e-mail address or linked identity (3.0)
4094409A queued job is running and cannot be deleted (DELETE /system/queue/{id}, 3.1.0)
4092409A write based on an outdated version (versioned); current holds the stored document, in the extendedJson mode of the request (2.6)
4121412Job already added
4131413The body is greater than BODY_MAX_BYTES (2.6)
4132413The uploaded file is greater than GRIDFS_UPLOAD_MAX_BYTES (2.6)
4133413The import is greater than IMPORT_MAX_BYTES (2.6)
4281428A versioned collection with required: true got a write without version
4401, 4402400Bad insert request, id missing for replace
4403400A token of an auth flow (verification, reset, invitation, magic link) that is used, expired or unknown (3.0)
5011501Live updates need a replica set or a sharded cluster
5031503Image 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:

StatusCases
400an 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)
404an index or collection that does not exist
409a duplicate key, also when a unique index is created over duplicate data, or a conflicting index
500everything 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:

json
{
  "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.

Released under the MIT License.