{"record":{"id":"1b69bb1769b547ff","repo":"apple/pkl","slug":"cannotanalyzerelativemoduleuri","errorCode":"cannotAnalyzeRelativeModuleUri","errorMessage":"cannotAnalyzeRelativeModuleUri","messagePattern":"cannotAnalyzeRelativeModuleUri","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/stdlib/analyze/AnalyzeNodes.java","lineNumber":86,"sourceCode":"\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) {\n        throw exceptionBuilder().withCause(e).build();\n      }\n    }\n  }\n}\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/stdlib/analyze/AnalyzeNodes.java#L68-L104","documentation":"After successfully constructing the URI in AnalyNodes.eval, each module URI must be absolute (have a scheme such as `file:`, `https:`, `projectpackage:`). A relative URI like \"mod.pkl\" cannot be resolved by the analyzer, so it throws `cannotAnalyzeRelativeModuleUri` for that value.","triggerScenarios":"Calling the analyze evaluator with a `moduleUris` entry that parses as a URI but has no scheme — e.g. \"mod.pkl\" or \"../lib/mod.pkl\" — hitting the `!uri.isAbsolute()` check at AnalyzeNodes.java:86.","commonSituations":"Passing plain relative file paths instead of `file:///` absolute URIs, or omitting the scheme when configuring the module set to analyze in tooling that feeds the analyze stdlib module.","solutions":["Prefix relative paths with the absolute scheme/authority: convert \"mod.pkl\" to \"file:///abs/path/mod.pkl\".","Resolve relative paths against a base directory before adding them to moduleUris.","Check each URI has a scheme (String.contains(\":\") before the first \"/\") before invoking the analyzer."],"exampleFix":"// before\nmoduleUris = List(\"mod.pkl\")\n// after\nmoduleUris = List(\"file:///home/user/project/mod.pkl\")","handlingStrategy":"validation","validationCode":"function isAbsoluteUri(s) {\n  return /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(s); // has a scheme\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve relative paths against a base directory before adding to moduleUris","Always include a scheme (file:, https:, projectpackage:)","Unit-test the module URI list construction"],"tags":["pkl","uri","analyze","relative-path"],"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"}