{"record":{"id":"e071bc7776a538bf","repo":"SeleniumHQ/selenium","slug":"detector-must-respond-to-call","errorCode":null,"errorMessage":"detector must respond to #call","messagePattern":"detector must respond to #call","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb","lineNumber":53,"sourceCode":"        #\n        # Example:\n        #\n        #     driver = Selenium::WebDriver.for :remote\n        #     driver.file_detector = lambda do |args|\n        #        # args => [\"/path/to/file\"]\n        #        str = args.first.to_s\n        #        str if File.exist?(str)\n        #     end\n        #\n        #     driver.find_element(:id => \"upload\").send_keys \"/path/to/file\"\n        #\n        # By default, no file detection is performed.\n        #\n        # @api public\n        #\n\n        def file_detector=(detector)\n          raise ArgumentError, 'detector must respond to #call' unless detector.nil? || detector.respond_to?(:call)\n\n          bridge.file_detector = detector\n        end\n      end # UploadsFiles\n    end # DriverExtensions\n  end # WebDriver\nend # Selenium\n","sourceCodeStart":35,"sourceCodeEnd":61,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb#L35-L61","documentation":"UploadsFiles#file_detector= validates that the detector is nil or an object responding to #call (i.e. a callable / proc / lambda). A non-callable value raises ArgumentError because the detector is later invoked with send_keys arguments to map them to file paths.","triggerScenarios":"Calling driver.file_detector = value where value is neither nil nor a callable — e.g. a String, a Class, an instance without a #call method, or an Array.","commonSituations":"Assigning a class name or method name instead of a proc, passing a custom object that forgets to define #call, intending 'auto-detect' but passing a non-callable sentinel.","solutions":["Assign a callable: driver.file_detector = ->(args) { ... } that returns a file path String or nil.","Pass nil to disable file detection.","Ensure any custom detector object implements #call (e.g. define def call(args) ... end).","Use a lambda/proc, not a method name or class."],"exampleFix":"// before\ndriver.file_detector = 'local'\ndriver.file_detector = MyUploader\n// after\ndriver.file_detector = ->(args) { args.first.to_s if File.exist?(args.first.to_s) }","handlingStrategy":"type-guard","validationCode":"def callable_detector?(d)\n  d.nil? || d.respond_to?(:call)\nend\n\nraise ArgumentError, 'detector must be callable' unless callable_detector?(detector)\ndriver.file_detector = detector","typeGuard":"def callable?(obj)\n  obj.respond_to?(:call)\nend","tryCatchPattern":"begin\n  driver.file_detector = detector\nrescue ArgumentError => e\n  raise unless e.message =~ /must respond to #call/\n  driver.file_detector = nil\nend","preventionTips":["Assign a lambda/proc (or nil to disable), never a Class or method name.","Ensure custom detector objects define #call.","Return a String path or nil from the detector."],"tags":["file-upload","file-detector","argument","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}