{"record":{"id":"c55e04ffc6ce30fe","repo":"apple/pkl","slug":"malformedproxyaddress","errorCode":"malformedProxyAddress","errorMessage":"malformedProxyAddress: ${proxyAddress}","messagePattern":"malformedProxyAddress: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/http/ProxySelector.java","lineNumber":46,"sourceCode":"final class ProxySelector extends java.net.ProxySelector {\n\n  public static final List<Proxy> NO_PROXY = List.of(Proxy.NO_PROXY);\n\n  private final @Nullable List<Proxy> myProxy;\n  private final List<NoProxyRule> noProxyRules;\n  private final java.net.@Nullable ProxySelector delegate;\n\n  ProxySelector(@Nullable URI proxyAddress, List<String> noProxyRules) {\n    this.noProxyRules = noProxyRules.stream().map(NoProxyRule::new).toList();\n    if (proxyAddress == null) {\n      this.delegate = java.net.ProxySelector.getDefault();\n      this.myProxy = null;\n    } else {\n      if (!proxyAddress.getScheme().equalsIgnoreCase(\"http\")\n          || proxyAddress.getHost() == null\n          || !proxyAddress.getPath().isEmpty()\n          || proxyAddress.getUserInfo() != null) {\n        throw new IllegalArgumentException(\n            ErrorMessages.create(\"malformedProxyAddress\", proxyAddress));\n      }\n      this.delegate = null;\n      var port = proxyAddress.getPort();\n      if (port == -1) {\n        port = 80;\n      }\n      this.myProxy =\n          List.of(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyAddress.getHost(), port)));\n    }\n  }\n\n  @Override\n  @ExplodeLoop\n  public List<Proxy> select(URI uri) {\n    for (var proxyRule : noProxyRules) {\n      if (proxyRule.matches(uri)) {\n        return NO_PROXY;","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/http/ProxySelector.java#L28-L64","documentation":"The proxy address configured for Pkl's HTTP client is not a valid HTTP proxy URI. ProxySelector's public constructor requires an http-scheme URL with a host, no path, and no userinfo; anything else throws this IllegalArgumentException.","triggerScenarios":"Creating an HTTP client (or setting the http.proxy config option / proxy environment) with an address that: uses a non-http scheme (e.g. https:// or socks5://), has no host, has a path component, or embeds user:password userinfo.","commonSituations":"Setting `proxy = \"https://proxy.corp:3128\"` when Pkl expects plain http for the CONNECT target, adding `http://user:pass@proxy:8080` credentials inline, or including a trailing path like `http://proxy:8080/`.","solutions":["Change the scheme to http:// (Pkl expects an http proxy address even for HTTPS tunneling via CONNECT).","Remove any path suffix and userinfo (user:password@) from the proxy URL.","Ensure the URL includes a hostname/IP, e.g. http://proxy.example.com:3128.","If the proxy needs auth, supply credentials through the library's supported proxy-auth mechanism rather than embedding them in the URL.","Check env vars (HTTP_PROXY/HTTPS_PROXY/ALL_PROXY) for malformed values Pkl may be consuming."],"exampleFix":"// before (pkl)\nhttp { proxy = \"https://user:pass@proxy.corp:3128/dashboard\" }\n// after (pkl)\nhttp { proxy = \"http://proxy.corp:3128\" }","handlingStrategy":"validation","validationCode":"URI proxy = URI.create(proxyAddress);\nboolean valid = \"http\".equalsIgnoreCase(proxy.getScheme())\n    && proxy.getHost() != null\n    && (proxy.getPath() == null || proxy.getPath().isEmpty())\n    && proxy.getUserInfo() == null;\nif (!valid) throw new IllegalArgumentException(\"Invalid proxy address: \" + proxyAddress);","typeGuard":null,"tryCatchPattern":"try {\n  // build HTTP client\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"malformedProxyAddress\")) {\n    // rewrite the proxy URL to http://host:port and retry\n  }\n}","preventionTips":["Always use the http:// scheme for proxy addresses.","Strip credentials and paths from proxy URLs; use the supported auth mechanism instead.","Validate HTTP_PROXY/HTTPS_PROXY env vars before launching.","Document the accepted proxy format for your team."],"tags":["http","proxy","configuration","url"],"backgroundTag":"invalid-url-format","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}