{"record":{"id":"ae9ff9ce36accecb","repo":"apple/pkl","slug":"invalidmoduleuri-ae9ff9","errorCode":"invalidModuleUri","errorMessage":"invalidModuleUri ${importUri}","messagePattern":"invalidModuleUri (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java","lineNumber":3228,"sourceCode":"        .withMemberName(symbolTable.getCurrentScope().getQualifiedName());\n  }\n\n  private SymbolTable.@Nullable Scope getParentLexicalScope() {\n    var parent = symbolTable.getCurrentScope().getLexicalScope().getParent();\n    if (parent != null) return parent.getLexicalScope();\n    return null;\n  }\n\n  private org.pkl.core.runtime.Identifier toIdentifier(String text) {\n    return org.pkl.core.runtime.Identifier.get(text);\n  }\n\n  private URI resolveImport(String importUri, StringConstant ctx) {\n    URI parsedUri;\n    try {\n      parsedUri = IoUtils.toUri(importUri);\n    } catch (URISyntaxException e) {\n      throw exceptionBuilder()\n          .evalError(\"invalidModuleUri\", importUri)\n          .withHint(e.getReason())\n          .withSourceSection(createSourceSection(ctx))\n          .build();\n    }\n    URI resolvedUri;\n    var context = VmContext.get(null);\n    try {\n      resolvedUri = IoUtils.resolve(context.getSecurityManager(), moduleKey, parsedUri);\n    } catch (FileNotFoundException e) {\n\n      var exceptionBuilder =\n          exceptionBuilder()\n              .evalError(\"cannotFindModule\", importUri)\n              .withSourceSection(createSourceSection(ctx));\n      var path = parsedUri.getPath();\n      if (path != null && path.contains(\"\\\\\")) {\n        exceptionBuilder.withHint(","sourceCodeStart":3210,"sourceCodeEnd":3246,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java#L3210-L3246","documentation":"An import URI string failed to parse as a URI (`IoUtils.toUri` raised URISyntaxException) while resolving an `import` statement. The error carries the offending import string and a hint from the parser about why the URI is malformed.","triggerScenarios":"An `import \"...\"` statement whose string is not a valid URI — illegal characters, spaces, unescaped `|`/`#`, malformed percent-encoding, or a scheme-less relative path containing URI-invalid characters.","commonSituations":"File paths with spaces pasted into imports; Windows `C:\\...` paths without `file:///`; special characters in module names not URL-encoded.","solutions":["Fix the import string so it is a valid URI (read the parser hint attached to the error)","Percent-encode spaces and special characters","Use forward slashes and a proper `file:///` scheme for absolute file imports","Use a relative path only when it is a valid URI reference"],"exampleFix":"// before\nimport \"my modules/config.pkl\"\n// after\nimport \"my%20modules/config.pkl\"\n","handlingStrategy":"validation","validationCode":"function isValidImportUri(s) {\n  try { new URL(s, 'file:///'); return true } catch { return false }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Percent-encode spaces and reserved characters in import strings","Use forward slashes; never paste raw filesystem paths with `\\`","Run `pkl eval` early in CI to catch malformed imports"],"tags":["pkl","import","uri","syntax-error"],"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"}