-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Optimization
Our test performing a distinct(nil) operation began failing today with the following message:
Mongo::Error::OperationFailure: FieldPath cannot be constructed with empty string (40352) (on localhost:27017, attempt 1) (on localhost:27017, attempt 1)
This is the line of code that is failing:
view.distinct(nil)
... which constructs the following command document:
def distinct(field_name, opts = {}) cmd = { :distinct => collection.name, :key => field_name.to_s, :query => filter }
The error is generated thusly:
FieldPath::FieldPath(std::string inputPath) : _fieldPath(std::move(inputPath)), _fieldPathDotPosition{string::npos} { uassert(40352, "FieldPath cannot be constructed with empty string", !_fieldPath.empty()); uassert(40353, "FieldPath must not end with a '.'.", _fieldPath[_fieldPath.size() - 1] != '.');
The error returned by the server to the client/driver should indicate what was wrong in the input provided to the server. In this case, I expect the error to resemble something like "Empty `key` is not allowed with `distinct`", referring to the input provided to the server. The actual error references "FieldPath" which is an internal implementation aspect of the server and not anything a user/application/driver knows.
- is related to
-
RUBY-1945 Prohibit distinct(nil) call as server 4.4 rejects it
- Closed