{"record":{"id":"516051ad637628ec","repo":"SeleniumHQ/selenium","slug":"num-is-not-a-klass","errorCode":null,"errorMessage":"#{num} is not a #{klass}","messagePattern":"#(.+?) is not a #(.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/common/interactions/pointer_event_properties.rb","lineNumber":52,"sourceCode":"        def process_opts\n          raise ArgumentError, \"Unknown options found: #{@opts.inspect}\" unless (@opts.keys - VALID.keys).empty?\n\n          VALID.each_with_object({}) do |(key, val), hash|\n            next unless @opts.key?(key)\n\n            name = val.keys.first\n            values = val.values.first\n            hash[name] = assert_number(@opts[key], values[:min], values[:max])\n          end\n        end\n\n        private\n\n        def assert_number(num, min, max = nil)\n          return if num.nil?\n\n          klass = min.is_a?(Integer) ? Integer : Numeric\n          raise TypeError, \"#{num} is not a #{klass}\" unless num.is_a?(klass)\n\n          raise ArgumentError, \"#{num} is not greater than or equal to #{min}\" if num < min\n\n          raise ArgumentError, \"#{num} is not less than or equal to #{max}\" if max && num > max\n\n          num\n        end\n      end # PointerEventProperties\n    end # Interactions\n  end # WebDriver\nend # Selenium\n","sourceCodeStart":34,"sourceCodeEnd":64,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/interactions/pointer_event_properties.rb#L34-L64","documentation":"Raised as TypeError by PointerEventProperties.assert_number when a pointer-event property value is non-nil but the wrong numeric type. The expected class is chosen from the VALID range: if the property's min is an Integer (tilt_x, tilt_y, twist) the value must be an Integer; otherwise (width, height, pressure, tangential_pressure, altitude_angle, azimuth_angle — min is a Float) any Numeric is accepted.","triggerScenarios":"Passing a Float where an Integer is required, e.g. tilt_x: 45.0 or twist: 90.5; passing a String like pressure: '0.5'; passing a Rational/Complex for a Float-typed property is fine (Numeric) but a String is not.","commonSituations":"Computing tilt/twist from trigonometry (returns Float) and feeding it directly; reading values from JSON/config as strings and not converting; mixing up which properties are integer-valued.","solutions":["Convert the value to the expected type before passing: use .to_i for tilt_x/tilt_y/twist and .to_f for the Float-typed properties.","For tilt_x/tilt_y/twist pass plain Integers (e.g. tilt_x: 45, not 45.0).","If loading from config, coerce: Integer(val) for integer props, Float(val) for float props, with rescue for bad strings."],"exampleFix":"# before\ndriver.action.pointer_down(:pen_contact, tilt_x: 45.0, twist: 90.5).perform # => TypeError: 45.0 is not an Integer\n\n# after\ndriver.action.pointer_down(:pen_contact, tilt_x: 45, twist: 90).perform","handlingStrategy":"validation","validationCode":"# Coerce to the expected type before passing\nINTEGER_PROPS = %i[tilt_x tilt_y twist].freeze\ndef coerce(prop, val)\n  return nil if val.nil?\n  INTEGER_PROPS.include?(prop) ? Integer(val) : Float(val)\nrescue ArgumentError\n  raise \"#{prop} value #{val.inspect} is not numeric\"\nend\n\ndriver.action.pointer_down(:pen_contact, tilt_x: coerce(:tilt_x, computed)).perform","typeGuard":"def numeric_for_prop?(prop, val)\n  return true if val.nil?\n  integer_prop = %i[tilt_x tilt_y twist].include?(prop)\n  integer_prop ? val.is_a?(Integer) : val.is_a?(Numeric)\nend","tryCatchPattern":null,"preventionTips":["Remember tilt_x/tilt_y/twist require Integer; the angle/pressure/size properties accept any Numeric.","Coerce values loaded from config (strings) with Integer()/Float() before passing."],"tags":["interactions","pointer-properties","typecheck","numeric","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}