{"record":{"id":"10668d49145207d1","repo":"mongodb/mongoid","slug":"mongoid-errors-messages-invalid-field-operator-mes","errorCode":null,"errorMessage":"mongoid.errors.messages.invalid_field_operator.message","messagePattern":"mongoid\\.errors\\.messages\\.invalid_field_operator\\.message","errorType":"exception","errorClass":"Mongoid::Errors::InvalidFieldOperator","httpStatus":null,"severity":"error","filePath":"lib/mongoid/matcher/field_operator.rb","lineNumber":44,"sourceCode":"        '$regex' => Regex,\n        '$size' => Size,\n        '$type' => Type\n      }.freeze\n\n      # Returns the matcher module for a given operator.\n      #\n      # @param [ String ] op The operator name.\n      #\n      # @return [ Module ] The matcher module.\n      #\n      # @raises [ Mongoid::Errors::InvalidFieldOperator ]\n      #   Raised if the given operator is unknown.\n      #\n      # @api private\n      module_function def get(op)\n        MAP.fetch(op)\n      rescue KeyError\n        raise Errors::InvalidFieldOperator.new(op)\n      end\n\n      # Used for evaluating $lt, $lte, $gt, $gte comparison operators.\n      #\n      # @todo Refactor this as it is only relevant to $lt, $lte, $gt, $gte.\n      #\n      # @api private\n      module_function def apply_array_field_operator(_exists, value, _condition, &block)\n        if value.is_a?(Array)\n          value.any?(&block)\n        else\n          yield value\n        end\n      end\n\n      # Used for evaluating $lt, $lte, $gt, $gte comparison operators.\n      #\n      # @todo Refactor this as it is only relevant to $lt, $lte, $gt, $gte.","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/matcher/field_operator.rb#L26-L62","documentation":"Raised by FieldOperator.get when a '$'-prefixed key in a field-level condition hash is not found in the field operator MAP. It is the standard 'unknown query operator' signal for in-memory matching, resolved through the InvalidFieldOperator error class.","triggerScenarios":"Thrown at lib/mongoid/matcher/field_operator.rb:44 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a valid field operator such as $eq, $ne, $gt, $gte, $in, $nin, $regex, $size, or $type","Check for typos in the operator name","Move logical combinators ($and, $or, $not) to the expression level, not inside a field condition"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","contentChangedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}