{"record":{"id":"5d7cb992da3eefd3","repo":"apple/pkl","slug":"invalidmoduleuri-5d7cb9","errorCode":"invalidModuleUri","errorMessage":"invalidModuleUri","messagePattern":"invalidModuleUri","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/runtime/VmImportAnalyzer.java","lineNumber":137,"sourceCode":"        } else {\n          var resolvedUri =\n              IoUtils.resolve(securityManager, moduleKey, IoUtils.toUri(entry.stringValue()));\n          var mKey = moduleResolver.resolve(resolvedUri);\n          var rmk = mKey.resolve(securityManager);\n          result.add(new ImportEntry(resolvedUri, rmk));\n        }\n      } catch (InvalidGlobPatternException e) {\n        throw new VmExceptionBuilder()\n            .evalError(\"invalidGlobPattern\", entry.stringValue())\n            .withSourceSection(entry.sourceSection())\n            .build();\n      } catch (FileNotFoundException | NoSuchFileException e) {\n        throw new VmExceptionBuilder()\n            .evalError(\"cannotFindModule\", entry.stringValue())\n            .withSourceSection(entry.sourceSection())\n            .build();\n      } catch (URISyntaxException e) {\n        throw new VmExceptionBuilder()\n            .evalError(\"invalidModuleUri\", entry.stringValue())\n            .withHint(e.getReason())\n            .withSourceSection(entry.sourceSection())\n            .build();\n      } catch (IOException e) {\n        throw new VmExceptionBuilder()\n            .evalError(\"ioErrorLoadingModule\", entry.stringValue())\n            .withCause(e)\n            .withSourceSection(entry.sourceSection())\n            .build();\n      } catch (SecurityManagerException | PackageLoadError e) {\n        throw new VmExceptionBuilder()\n            .withSourceSection(entry.sourceSection())\n            .withCause(e)\n            .build();\n      } catch (ExternalReaderProcessException e) {\n        throw new VmExceptionBuilder()\n            .withSourceSection(entry.sourceSection())","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/runtime/VmImportAnalyzer.java#L119-L155","documentation":"Sentinel evalError 'invalidModuleUri' raised by VmImportAnalyzer.collectImports: a module import URI collected during analyzer traversal could not be resolved through IoUtils.resolve/moduleResolver, i.e. an import statement in the analyzed module refers to a malformed or unresolvable URI.","triggerScenarios":"import(\"htp:/bad uri.pkl\") or other malformed URIs (illegal characters, spaces, bad scheme syntax) during collectImports.","commonSituations":"Spaces or unencoded special characters in paths; missing scheme; accidentally interpolating an invalid value into the import string.","solutions":["Fix the import URI in the Pkl source to be a valid absolute or resolvable relative URI.","Check for typos or unsupported schemes in the import path."],"exampleFix":"// before\nimport(\"my modules/a.pkl\")\n// after\nimport(\"my%20modules/a.pkl\")","handlingStrategy":"validation","validationCode":"function assertValidUri(u) { try { new URL(u) } catch (e) { throw new Error('invalid module URI: ' + u + ' (' + e.message + ')') } }","typeGuard":"const isValidUri = (u) => { try { new URL(u); return true } catch { return false } };","tryCatchPattern":null,"preventionTips":["Percent-encode spaces and special characters in URIs","Prefer relative paths for local modules","Validate dynamically built import strings"],"tags":["pkl","uri","import"],"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"}