|
|
@@ -69,6 +69,26 @@ ApiError translate(Code code, const std::string& message, const std::string& not
|
|
|
// `validation` answer would send a caller looking for.
|
|
|
if (reason == "document_too_large")
|
|
|
return ApiError(ErrCode::Unprocessable, "document_too_large", message, details);
|
|
|
+ if (reason == "encrypted_field")
|
|
|
+ // database 2.17.0 encrypts any field named password, secret,
|
|
|
+ // token, api_key, apiKey or credentials at ANY depth, in EVERY
|
|
|
+ // collection, and then REFUSES a filter, sort, index, unique
|
|
|
+ // constraint, relation or increment on one.
|
|
|
+ //
|
|
|
+ // Its own slug, not the generic `validation`, because the
|
|
|
+ // remedy is unlike every other validation failure: the request
|
|
|
+ // is well formed and the field is spelled correctly, and no
|
|
|
+ // amount of correcting the body helps. The caller has to stop
|
|
|
+ // querying that field - store a non-sensitive duplicate to
|
|
|
+ // query by (a hash, or a boolean "set"), or rename the field if
|
|
|
+ // it was never a credential.
|
|
|
+ //
|
|
|
+ // Worth knowing what it REPLACES, because the old behaviour was
|
|
|
+ // worse: before 2.17.0 a top-level field of those names was
|
|
|
+ // plaintext and filterable, and a NESTED one compared ciphertext
|
|
|
+ // and silently matched nothing. So this refusal turns a silently
|
|
|
+ // empty result into a visible error.
|
|
|
+ return ApiError(ErrCode::Unprocessable, "encrypted_field", message, details);
|
|
|
return ApiError(ErrCode::Unprocessable, "validation", message);
|
|
|
case Code::OutOfRange:
|
|
|
return ApiError(ErrCode::Unprocessable, "validation", message);
|