{"record":{"id":"760e2d3ccf7a02dc","repo":"arduino/Arduino","slug":"unable-to-understand-proxy-settings","errorCode":null,"errorMessage":"Unable to understand proxy settings","messagePattern":"Unable to understand proxy settings","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"arduino-core/src/cc/arduino/net/CustomProxySelector.java","lineNumber":74,"sourceCode":"\n    if (Constants.PROXY_TYPE_NONE.equals(proxyType)) {\n      return Proxy.NO_PROXY;\n    }\n\n    if (Constants.PROXY_TYPE_AUTO.equals(proxyType)) {\n      String pac = preferences.get(Constants.PREF_PROXY_PAC_URL);\n      if (pac == null || pac.isEmpty()) {\n        return ProxySelector.getDefault().select(uri).get(0);\n      }\n\n      return pacProxy(pac, uri);\n    }\n\n    if (Constants.PROXY_TYPE_MANUAL.equals(proxyType)) {\n      return manualProxy();\n    }\n\n    throw new IllegalStateException(\"Unable to understand proxy settings\");\n  }\n\n  private Proxy pacProxy(String pac, URI uri) throws IOException, ScriptException, NoSuchMethodException {\n    setAuthenticator(preferences.get(Constants.PREF_PROXY_USERNAME), preferences.get(Constants.PREF_PROXY_PASSWORD));\n\n    URLConnection urlConnection = new URL(pac).openConnection();\n    urlConnection.connect();\n    if (urlConnection instanceof HttpURLConnection) {\n      int responseCode = ((HttpURLConnection) urlConnection).getResponseCode();\n      if (responseCode != 200) {\n        throw new IOException(\"Unable to fetch PAC file at \" + pac + \". Response code is \" + responseCode);\n      }\n    }\n    String pacScript = new String(IOUtils.toByteArray(urlConnection.getInputStream()), Charset.forName(\"ASCII\"));\n\n    ScriptEngine nashorn = new ScriptEngineManager().getEngineByName(\"nashorn\");\n    nashorn.getBindings(ScriptContext.ENGINE_SCOPE).put(\"pac\", new PACSupportMethods());\n    Stream.of(\"isPlainHostName(host)\",","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/cc/arduino/net/CustomProxySelector.java#L56-L92","documentation":"CustomProxySelector.getProxyFor() dispatches on the configured proxy type (auto/PAC, manual, none via earlier branches). If Constants.PREF_PROXY_TYPE holds a value matching none of the known branches, it falls through and throws an IllegalStateException, indicating the proxy settings in preferences are unrecognizable.","triggerScenarios":"getProxyFor() (called from proxy()) reads Constants.PREF_PROXY_TYPE and the value is not PROXY_TYPE_AUTO/PAC, not PROXY_TYPE_MANUAL, and not the none/system alternatives handled earlier — e.g. a typo'd or foreign value in preferences.txt.","commonSituations":"Hand-edited preferences.txt with an invalid proxy type string; a downgrade/upgrade where preference key values changed between IDE versions; provisioning tools writing 'PAC'/'socks' or other unsupported values.","solutions":["Set the proxy type preference to a supported value (none/auto/manual) in preferences.txt or File > Preferences.","Delete the invalid proxy type preference entry so defaults are used, then reconfigure the proxy.","Check for case/whitespace errors in the stored value and match exactly what Constants.PREF_PROXY_TYPE expects.","If an external tool sets this preference, fix its writer to emit only recognized enum values."],"exampleFix":"// before (preferences.txt)\nproxy.type=SOCKS5\n// after\nproxy.type=MANUAL","handlingStrategy":"validation","validationCode":"String type = preferences.get(Constants.PREF_PROXY_TYPE);\nSet<String> valid = Set.of(Constants.PROXY_TYPE_NONE, Constants.PROXY_TYPE_AUTO, Constants.PROXY_TYPE_MANUAL);\nif (type != null && !valid.contains(type)) { throw new IllegalStateException(\"Unsupported proxy type: \" + type); }","typeGuard":null,"tryCatchPattern":"try { Proxy p = new CustomProxySelector(prefs).getProxyFor(uri); } catch (IllegalStateException e) { if (e.getMessage().contains(\"Unable to understand proxy settings\")) { resetProxyPreferences(); } else { throw e; } }","preventionTips":["Only write recognized proxy type values into preferences.","Validate preferences.txt after hand edits or provisioning.","Reconfigure proxy settings after IDE version migrations."],"tags":["arduino","proxy","configuration","network"],"backgroundTag":"invalid-config-value","analyzedSha":"a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee","analyzedAt":"2026-09-06T10:13:38.901Z","contentChangedAt":"2026-09-06T10:13:38.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}