{"record":{"id":"1d8566954df42b09","repo":"SeleniumHQ/selenium","slug":"expected-one-of-valid-preference-types-inspect","errorCode":null,"errorMessage":"expected one of #{VALID_PREFERENCE_TYPES.inspect}, got #{value.inspect}:#{value.class}","messagePattern":"expected one of #(.+?), got #(.+?):#(.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/firefox/profile.rb","lineNumber":101,"sourceCode":"\n          install_extensions(profile_dir)\n          delete_lock_files(profile_dir)\n          delete_extensions_cache(profile_dir)\n          update_user_prefs_in(profile_dir)\n\n          profile_dir\n        end\n\n        #\n        # Set a preference for this particular profile.\n        #\n        # @see http://kb.mozillazine.org/About:config_entries\n        # @see http://preferential.mozdev.org/preferences.html\n        #\n\n        def []=(key, value)\n          unless VALID_PREFERENCE_TYPES.any? { |e| value.is_a? e }\n            raise TypeError, \"expected one of #{VALID_PREFERENCE_TYPES.inspect}, got #{value.inspect}:#{value.class}\"\n          end\n\n          if value.is_a?(String) && Util.stringified?(value)\n            raise ArgumentError, \"preference values must be plain strings: #{key.inspect} => #{value.inspect}\"\n          end\n\n          @additional_prefs[key.to_s] = value\n        end\n\n        def port=(port)\n          WebDriver.logger.deprecate('Firefox::Profile#port=', 'the Service class', id: :firefox_profile)\n          self[WEBDRIVER_PREFS[:port]] = port\n        end\n\n        def secure_ssl=(value)\n          WebDriver.logger.deprecate('Firefox::Profile#secure_ssl=', id: :firefox_profile)\n          @secure_ssl = value\n        end","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/firefox/profile.rb#L83-L119","documentation":"Raised by Firefox::Profile#[]= (TypeError) when the preference value is not one of VALID_PREFERENCE_TYPES ([TrueClass, FalseClass, Integer, Float, String]). Firefox about:config preferences only accept boolean, numeric, or string scalar values, so the setter rejects anything else (arrays, hashes, symbols, nil).","triggerScenarios":"Calling profile[key] = value with a Symbol (e.g. :none), an Array, a Hash, nil, or any non-scalar; passing a numeric as a string when a real number was intended is fine, but a Symbol like :auto will fail.","commonSituations":"Copying preference values from documentation that use symbols; deserializing JSON config into nested structures and assigning a Hash; passing nil to 'unset' a preference (not supported).","solutions":["Convert the value to one of the allowed types before assigning (symbol->string via to_s, etc.).","Use true/false for booleans, integers/floats for numbers, and plain strings for text.","If you need to remove a preference, manage the underlying prefs hash directly rather than assigning nil."],"exampleFix":"// before\nprofile['network.proxy.type'] = :auto  # Symbol -> TypeError\n\n// after\nprofile['network.proxy.type'] = 'auto'  # plain string\n# or for known numeric codes\nprofile['network.proxy.type'] = 4","handlingStrategy":"type-guard","validationCode":"ALLOWED = [TrueClass, FalseClass, Integer, Float, String]\nvalue = coerce(value) unless ALLOWED.any? { |t| value.is_a?(t) }\nprofile[key] = value","typeGuard":"def valid_pref_value?(value)\n  [TrueClass, FalseClass, Integer, Float, String].any? { |t| value.is_a?(t) }\nend","tryCatchPattern":null,"preventionTips":["Only assign boolean, integer, float, or plain string preference values.","Convert symbols/other types to strings via to_s before assigning.","Never assign nil, arrays, or hashes to a Firefox preference."],"tags":["firefox","profile","type-error","preferences"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}