{"record":{"id":"9ab0a521d08d24b1","repo":"SeleniumHQ/selenium","slug":"preference-values-must-be-plain-strings-key-ins","errorCode":null,"errorMessage":"preference values must be plain strings: #{key.inspect} => #{value.inspect}","messagePattern":"preference values must be plain strings: #(.+?) => #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/firefox/profile.rb","lineNumber":105,"sourceCode":"          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\n\n        def load_no_focus_lib=(value)\n          WebDriver.logger.deprecate('Firefox::Profile#load_no_focus_lib=', id: :firefox_profile)\n          @load_no_focus_lib = value","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/firefox/profile.rb#L87-L123","documentation":"Raised by Firefox::Profile#[]= (ArgumentError) when the value is a String but Util.stringified?(value) is true — i.e. the string already looks like a stringified literal (it appears quoted/encoded). Firefox preferences must be plain unquoted strings; a value like \"'true'\" or '\\\"100\\\"' would be double-encoded when serialized to prefs.js.","triggerScenarios":"Passing a string that begins/ends with quotes (e.g. '\"true\"', \"'100'\") or otherwise looks pre-stringified to profile[]=.","commonSituations":"Values read from JSON/YAML that retained surrounding quotes; copy-pasting example values that include quote characters; building preference strings via interpolation that adds quotes.","solutions":["Pass the raw unquoted string (e.g. 'true' not '\"true\"').","If the value genuinely needs to be a non-string type, pass the actual boolean/number instead of its string form.","Strip accidental surrounding quotes before assigning."],"exampleFix":"// before\nprofile['my.pref'] = '\"enabled\"'  # extra quotes -> ArgumentError\n\n// after\nprofile['my.pref'] = 'enabled'  # plain string","handlingStrategy":"validation","validationCode":"value = value.to_s\nvalue = value.gsub(/\\A['\"]+|['\"]+\\z/, '') if Selenium::WebDriver::Util.stringified?(value)\nprofile[key] = value","typeGuard":"def plain_string?(value)\n  value.is_a?(String) && !Selenium::WebDriver::Util.stringified?(value)\nend","tryCatchPattern":null,"preventionTips":["Pass raw unquoted strings as preference values.","Strip accidental surrounding quotes from values read out of JSON/YAML.","Use real booleans/numbers instead of their quoted string forms."],"tags":["firefox","profile","argument-error","preferences"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}