{"record":{"id":"098f6dc6bf272575","repo":"apple/pkl","slug":"invalidmoduleuri-098f6d","errorCode":"invalidModuleUri","errorMessage":"invalidModuleUri","messagePattern":"invalidModuleUri","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/stdlib/analyze/AnalyzeNodes.java","lineNumber":80,"sourceCode":"                var builder = VmMap.builder();\n                for (var entry : graph.resolvedImports().entrySet()) {\n                  builder.add(entry.getKey().toString(), entry.getValue().toString());\n                }\n                return builder.build();\n              });\n\n  public abstract static class importGraph extends ExternalMethod1Node {\n    @Specialization\n    @TruffleBoundary\n    protected Object eval(@SuppressWarnings(\"unused\") VmTyped self, VmSet moduleUris) {\n      var uris = new URI[moduleUris.getLength()];\n      var idx = 0;\n      for (var moduleUri : moduleUris) {\n        URI uri;\n        try {\n          uri = new URI((String) moduleUri);\n        } catch (URISyntaxException e) {\n          throw exceptionBuilder()\n              .evalError(\"invalidModuleUri\", moduleUri)\n              .withHint(e.getMessage())\n              .build();\n        }\n        if (!uri.isAbsolute()) {\n          throw exceptionBuilder().evalError(\"cannotAnalyzeRelativeModuleUri\", moduleUri).build();\n        }\n        uris[idx] = uri;\n        idx++;\n      }\n      var context = VmContext.get(this);\n      try {\n        var results = VmImportAnalyzer.analyze(uris, context);\n        return importGraphFactory.create(results);\n      } catch (IOException\n          | SecurityManagerException\n          | PackageLoadError\n          | ExternalReaderProcessException e) {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/stdlib/analyze/AnalyzeNodes.java#L62-L98","documentation":"AnalyzeNodes.eval (part of Pkl's `analyze` standard-library module) converts each entry of the `moduleUris` argument to a java.net.URI. If the string is not syntactically valid URI (per RFC 2396 as enforced by java.net.URI), it throws the `invalidModuleUri` eval error, attaching the underlying URISyntaxException message as a hint.","triggerScenarios":"Calling the analyze evaluator (AnalyzeNodes eval) with a `moduleUris` list containing a string that java.net.URI rejects — e.g. containing spaces, illegal characters like `{`, unmatched `%`, or a bare `#fragment` — at AnalyzeNodes.java:80.","commonSituations":"Passing unencoded Windows paths (\"C:\\dir\\mod.pkl\"), URIs with unencoded spaces, or file paths pasted from a shell into the moduleUris list instead of proper `file:///` URIs.","solutions":["Percent-encode the string before constructing the URI (e.g. via URLEncoder or encoding spaces as %20).","Convert plain file paths to proper `file:///` URIs.","Remove or escape illegal URI characters ({, }, |, \\, ^, spaces).","Read the hint in the error message — it contains the exact URISyntaxException from java.net.URI."],"exampleFix":"// before\nmoduleUris = List(\"C:\\my dir\\mod.pkl\")\n// after\nmoduleUris = List(\"file:///C:/my%20dir/mod.pkl\")","handlingStrategy":"validation","validationCode":"// Java: validate each module URI string\ntry {\n  URI u = new URI(s);\n  if (!u.isAbsolute()) throw new IllegalArgumentException(\"relative: \" + s);\n} catch (URISyntaxException e) { /* reject */ }","typeGuard":null,"tryCatchPattern":"try {\n  result = analyzer.eval(moduleUris);\n} catch (VmException e) {\n  if (e.getMessage().contains(\"invalidModuleUri\")) {\n    // fix/encode the offending URI and retry once\n  } else throw e;\n}","preventionTips":["Percent-encode spaces and illegal characters in URIs","Convert file paths to file:/// URIs","Validate with java.net.URI before passing to the analyzer"],"tags":["pkl","uri","analyze","invalid-input"],"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"}