{"record":{"id":"87fe4cb05dc7800f","repo":"apple/pkl","slug":"cannotfindresource-87fe4c","errorCode":"cannotFindResource","errorMessage":"cannotFindResource","messagePattern":"cannotFindResource","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/expression/unary/ReadGlobMemberBodyNode.java","lineNumber":50,"sourceCode":"  }\n\n  @Override\n  public Object executeGeneric(VirtualFrame frame) {\n    var mapping = VmUtils.getOwner(frame);\n    var path = (String) VmUtils.getMemberKey(frame);\n    return readResource(mapping, path);\n  }\n\n  private Object readResource(VmObjectLike mapping, String path) {\n    @SuppressWarnings(\"unchecked\")\n    var globElements = (Map<String, ResolvedGlobElement>) mapping.getExtraStorage();\n    var globElement = VmUtils.getMapValue(globElements, path);\n    assert globElement != null;\n    var resourceUri = globElement.uri();\n    var resource = VmContext.get(this).getResourceManager().read(resourceUri, this).orElse(null);\n    if (resource == null) {\n      CompilerDirectives.transferToInterpreter();\n      throw exceptionBuilder().evalError(\"cannotFindResource\", resourceUri).build();\n    }\n    return resource;\n  }\n}\n","sourceCodeStart":32,"sourceCodeEnd":55,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/expression/unary/ReadGlobMemberBodyNode.java#L32-L55","documentation":"Thrown while reading one element of a globbed resource (`read(...).text` etc.) when the resource manager cannot find a file for the matched URI. The glob matched the path, but the actual resource disappeared or is unreadable, so the lookup returns empty.","triggerScenarios":"Globbing resources (e.g. `read(\"*.txt\")` in a `read` glob context) where a matched file is deleted, moved, or excluded by a module path/security rule between match and read, making ResourceManager.read return empty.","commonSituations":"Files removed after glob listing, module-path changes excluding matched files, caching of glob results while files change on disk, typos in resource paths matched only loosely.","solutions":["Confirm the file at the reported URI still exists and is inside the module path/allowed roots.","Re-run so the glob re-resolves against the current directory contents.","Check pkl.modulePath and security manager include/exclude rules for the resource location.","If resources are generated, ensure generation completes before evaluation."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// before evaluating, ensure matched files exist:\n// ls <dir covered by glob>","typeGuard":null,"tryCatchPattern":"try {\n  processGlobbedResource(path)\n} catch (e) {\n  if (e.code === 'cannotFindResource') skipOrRegenerate(e.data.resourceUri)\n  else throw e\n}","preventionTips":["Ensure globbed files are not deleted between listing and read","Keep all globbed resources inside the module path","Generate resources before running evaluation","Re-resolve globs after filesystem changes"],"tags":["resource","glob","file-not-found"],"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-17T15:17:12.973Z"}