{"record":{"id":"7c72ddc45af23413","repo":"apple/pkl","slug":"cannotfindmoduleimport","errorCode":"cannotFindModuleImport","errorMessage":"cannotFindModuleImport","messagePattern":"cannotFindModuleImport","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/type/ResolveDeclaredTypeNode.java","lineNumber":52,"sourceCode":"    var curr = initialOwner;\n    var next = curr.getEnclosingOwner();\n\n    while (next != null) {\n      curr = next;\n      next = next.getEnclosingOwner();\n    }\n\n    assert curr.isModuleObject();\n    return (VmTyped) curr;\n  }\n\n  protected VmTyped getImport(\n      VmTyped module, Identifier importName, SourceSection importNameSection) {\n    assert importName.isLocalProp();\n\n    var member = module.getMember(importName);\n    if (member == null) {\n      throw exceptionBuilder()\n          .evalError(\"cannotFindModuleImport\", importName)\n          .withSourceSection(importNameSection)\n          .build();\n    }\n\n    if (!member.isImport()) {\n      throw exceptionBuilder()\n          .evalError(\"notAModuleImport\", importName)\n          .withSourceSection(importNameSection)\n          .build();\n    }\n\n    if (member.isGlob()) {\n      throw exceptionBuilder()\n          .evalError(\"notAType\", importName)\n          .withSourceSection(importNameSection)\n          .build();\n    }","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/type/ResolveDeclaredTypeNode.java#L34-L70","documentation":"`cannotFindModuleImport` is thrown by ResolveDeclaredTypeNode.getImport when resolving a qualified type like `mod.SomeType`: the referenced import name is not a member of the module. The module has no member with that identifier, so the qualified type cannot be resolved.","triggerScenarios":"Writing `foo.Bar` in a type position where `foo` is not an import/property of the current module; a typo in the import alias; the import was removed or renamed.","commonSituations":"Renaming an import alias without updating qualified type references; deleting an import statement still referenced in type annotations; referring to a module by filename instead of its import name.","solutions":["Add or fix the import declaration for the module referenced by the qualified name","Correct the import name/alias typo in the type annotation","Verify the member exists on the imported module (name and spelling)"],"exampleFix":"// before\nx: modu.Config\n// after (with `import \"config.pkl\" as mod`\nx: mod.Config","handlingStrategy":"validation","validationCode":"// ensure the import alias used in qualified types is declared\nif (!/^import\\s+\"[^\"]+\"\\s+as\\s+mod\\b/m.test(source)) console.error(\"missing import alias 'mod'\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep import aliases stable; rename via IDE refactor","Verify every qualified type's prefix has a matching import"],"tags":["pkl","import","type-resolution"],"backgroundTag":"resource-not-found","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"}