{"record":{"id":"7db9d8c0625efc54","repo":"mongodb/mongoid","slug":"cannot-translate-value-inspect-value-class","errorCode":null,"errorMessage":"cannot translate #{value.inspect} (#{value.class}) to a direction specification","messagePattern":"cannot translate #(.+?) \\(#(.+?)\\) to a direction specification","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/mongoid/criteria/translator.rb","lineNumber":38,"sourceCode":"      #   Translator.to_direction(\"1\")\n      #   Translator.to_direction(-1)\n      #   Translator.to_direction(score: { \"$meta\": \"textScore\" })\n      #\n      # @param [ Hash | Numeric | String | Symbol ] value The value to convert.\n      #\n      # @return [ Hash | Numeric ] The direction.\n      def to_direction(value)\n        case value\n        when Hash\n          value\n        when Numeric\n          value\n        when String\n          /desc/i.match?(value) ? -1 : 1\n        when Symbol\n          to_direction(value.to_s)\n        else\n          raise ArgumentError, \"cannot translate #{value.inspect} (#{value.class}) to a direction specification\"\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":20,"sourceCodeEnd":44,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/criteria/translator.rb#L20-L44","documentation":"Error \"cannot translate #{value.inspect} (#{value.class}) to a direction specification\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/criteria/translator.rb:38 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"}