{"record":{"id":"9b474d2fb40eb660","repo":"flippercloud/flipper","slug":"value-inspect-cannot-be-converted-to-a-number","errorCode":null,"errorMessage":"#{value.inspect} cannot be converted to a number","messagePattern":"#(.+?) cannot be converted to a number","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/flipper/typecast.rb","lineNumber":57,"sourceCode":"    end\n\n    # Internal: Convert value to a number.\n    #\n    # Returns a Integer or Float representation of the value.\n    # Raises ArgumentError if conversion is not possible.\n    def self.to_number(value)\n      case value\n      when Numeric\n        value\n      when String\n        value.include?('.') ? to_float(value) : to_integer(value)\n      when NilClass\n        0\n      else\n        value.to_f\n      end\n    rescue NoMethodError\n      raise ArgumentError, \"#{value.inspect} cannot be converted to a number\"\n    end\n    singleton_class.send(:alias_method, :to_percentage, :to_number)\n\n    # Internal: Convert value to a set.\n    #\n    # Returns a Set representation of the value.\n    # Raises ArgumentError if conversion is not possible.\n    def self.to_set(value)\n      return value if value.is_a?(Set)\n      return Set.new if value.nil? || value.empty?\n\n      if value.respond_to?(:to_set)\n        value.to_set\n      else\n        raise ArgumentError, \"#{value.inspect} cannot be converted to a set\"\n      end\n    end\n","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/flippercloud/flipper/blob/1f86de3ec91521585b156445e156642938b19cb0/lib/flipper/typecast.rb#L39-L75","documentation":"Error \"#{value.inspect} cannot be converted to a number\" thrown in flippercloud/flipper.","triggerScenarios":"Thrown at lib/flipper/typecast.rb:57 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an Integer, Float, or numeric String; other types cannot be converted to a number","Convert the value before passing it (to_i/to_f) if it comes from user input","Check for nil being passed where a percentage or count is expected"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1f86de3ec91521585b156445e156642938b19cb0","analyzedAt":"2026-08-23T04:36:09.896Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}