{"record":{"id":"b3b4c0cc3b524753","repo":"apple/pkl","slug":"invaliduri","errorCode":"invalidUri","errorMessage":"invalidUri: ${input}","messagePattern":"invalidUri: (.+?)","errorType":"validation","errorClass":"PklException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/evaluatorSettings/PklEvaluatorSettings.java","lineNumber":154,"sourceCode":"        return new Http(proxy, parsedRewrites, parsedHeaders);\n      } else {\n        throw PklBugException.unreachableCode();\n      }\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private static @Nullable Map<URI, URI> parseHttpRewrites(Object rewrites) {\n      if (rewrites instanceof PNull) {\n        return null;\n      }\n      var parsedRewrites = new HashMap<URI, URI>();\n      for (var entry : ((Map<String, String>) rewrites).entrySet()) {\n        var key = entry.getKey();\n        var value = entry.getValue();\n        try {\n          parsedRewrites.put(new URI(key), new URI(value));\n        } catch (URISyntaxException e) {\n          throw new PklException(ErrorMessages.create(\"invalidUri\", e.getInput()));\n        }\n      }\n      return parsedRewrites;\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private static @Nullable Map<String, Map<String, List<String>>> parseHttpHeaders(\n        Object headerDefs) {\n      if (headerDefs instanceof PNull) {\n        return null;\n      }\n      var defs = (Map<String, Map<String, Object>>) headerDefs;\n      var ret = new LinkedHashMap<String, Map<String, List<String>>>(defs.size());\n      for (var entry : defs.entrySet()) {\n        var headers = entry.getValue();\n        var map = new LinkedHashMap<String, List<String>>(headers.size());\n        for (var header : headers.entrySet()) {\n          var value = header.getValue();","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/evaluatorSettings/PklEvaluatorSettings.java#L136-L172","documentation":"PklEvaluatorSettings.parseHttpRewrites converts the http proxy 'rewrites' map entries from strings to java.net.URI objects. When any key or value string is not a valid URI per RFC 2396, URI() throws URISyntaxException and this PklException with code 'invalidUri' is thrown, embedding the offending input string.","triggerScenarios":"Calling PklEvaluatorSettings with an http rewrites map whose key or value (e.g. 'https://old.com' -> 'https://new.com') fails URI parsing — malformed scheme, illegal characters like spaces or '{', or missing scheme.","commonSituations":"Typos in rewrite URLs (missing scheme like 'new.example.com'), unencoded characters in URLs, templated values not yet interpolated, copy-pasted URLs with surrounding whitespace or quotes.","solutions":["Print and inspect the offending string in the error message; fix the key or value in the rewrites map to be a valid URI","Add an explicit scheme (http:// or https://) to the URL","URL-encode illegal characters (spaces, non-ASCII) or strip them","Trim whitespace and stray quotes from the map key/value"],"exampleFix":"// before\n\"http\": { rewrites: { \"old.example.com\": \"new.example.com\" } }\n// after\n\"http\": { rewrites: { \"https://old.example.com\": \"https://new.example.com\" } }","handlingStrategy":"validation","validationCode":"static URI requireUri(String s) {\n  try { return new URI(s.trim()); }\n  catch (URISyntaxException e) { throw new IllegalArgumentException(\"Not a valid URI: \" + s, e); }\n}\n// validate each key/value of the rewrites map before constructing PklEvaluatorSettings","typeGuard":"boolean isValidUri(String s) {\n  if (s == null) return false;\n  try { new URI(s.trim()); return true; } catch (URISyntaxException e) { return false; }\n}","tryCatchPattern":"try {\n  evaluatorSettings.apply(...);\n} catch (PklException e) {\n  if (e.getMessage().startsWith(\"invalidUri\")) {\n    // surface the offending string from the message and fix the config\n  }\n}","preventionTips":["Always include an explicit scheme in rewrite keys and values","Trim whitespace from config strings read from files/env vars","Validate all rewrite map entries with new URI(...) at config-load time","Avoid raw templating placeholders like ${...} in URLs"],"tags":["pkl","uri","configuration","proxy"],"backgroundTag":"invalid-url","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"}