Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-43613

"FieldPath cannot be constructed with empty string (40352)" message does not refer to user input

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 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.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: