{"record":{"id":"aec2e7987183ba2e","repo":"mongodb/mongoid","slug":"not-argument-must-be-a-hash-or-a-regular-expressi","errorCode":null,"errorMessage":"$not argument must be a Hash or a regular expression: #{Errors::InvalidQuery.truncate_expr(condition)}","messagePattern":"\\$not argument must be a Hash or a regular expression: #(.+?)","errorType":"exception","errorClass":"Mongoid::Errors::InvalidQuery","httpStatus":null,"severity":"error","filePath":"lib/mongoid/matcher/not.rb","lineNumber":37,"sourceCode":"      module_function def matches?(exists, value, condition)\n        case condition\n        when ::Regexp, BSON::Regexp::Raw\n          !Regex.matches?(exists, value, condition)\n        when Hash\n          if condition.empty?\n            raise Errors::InvalidQuery, \"$not argument cannot be an empty hash: #{Errors::InvalidQuery.truncate_expr(condition)}\"\n          end\n\n          condition.all? do |(k, cond_v)|\n            k = k.to_s\n            unless k.start_with?('$')\n              raise Errors::InvalidQuery, \"$not arguments must be operators: #{Errors::InvalidQuery.truncate_expr(k)}\"\n            end\n\n            !FieldOperator.get(k).matches?(exists, value, cond_v)\n          end\n        else\n          raise Errors::InvalidQuery, \"$not argument must be a Hash or a regular expression: #{Errors::InvalidQuery.truncate_expr(condition)}\"\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":19,"sourceCodeEnd":43,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/matcher/not.rb#L19-L43","documentation":"Error \"$not argument must be a Hash or a regular expression: #{Errors::InvalidQuery.truncate_expr(condition)}\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/matcher/not.rb:37 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}