{"record":{"id":"0a8924ae8264a7b5","repo":"apple/pkl","slug":"cannotgloburi-0a8924","errorCode":"cannotGlobUri","errorMessage":"cannotGlobUri","messagePattern":"cannotGlobUri","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/expression/unary/ReadGlobNode.java","lineNumber":83,"sourceCode":"\n  @Specialization\n  @TruffleBoundary\n  public Object read(String globPattern) {\n    var cachedResult = cachedResults.get(globPattern);\n    //noinspection ConstantValue\n    if (cachedResult != null) return cachedResult;\n\n    // use same check as for globbed imports (see AstBuilder)\n    if (globPattern.startsWith(\"...\")) {\n      throw exceptionBuilder().evalError(\"cannotGlobTripleDots\").build();\n    }\n    var globUri = parseUri(globPattern);\n    var context = VmContext.get(this);\n    try {\n      var resolvedUri = IoUtils.resolve(context.getSecurityManager(), currentModule, globUri);\n      var reader = context.getResourceManager().getReader(resolvedUri, this);\n      if (!reader.isGlobbable()) {\n        throw exceptionBuilder().evalError(\"cannotGlobUri\", globUri, globUri.getScheme()).build();\n      }\n      var resolvedElements =\n          GlobResolver.resolveGlob(\n              context.getSecurityManager(),\n              reader,\n              currentModule,\n              currentModule.getUri(),\n              globPattern);\n      var builder = new VmObjectBuilder(resolvedElements.size());\n      for (var entry : resolvedElements.entrySet()) {\n        builder.addEntry(entry.getKey(), getMemberNode());\n      }\n      cachedResult = builder.toMapping(resolvedElements);\n      cachedResults.put(globPattern, cachedResult);\n      return cachedResult;\n    } catch (IOException e) {\n      throw exceptionBuilder().evalError(\"ioErrorResolvingGlob\", globPattern).withCause(e).build();\n    } catch (SecurityManagerException | HttpClientException | URISyntaxException e) {","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/expression/unary/ReadGlobNode.java#L65-L101","documentation":"Thrown when a glob is attempted against a URI whose scheme's reader does not support globbing (reader.isGlobbable() is false). Only certain resource types (e.g. local files, module paths) can be globbed; HTTP and most external readers cannot list matches.","triggerScenarios":"Calling `read*(\"https://example.com/*.json\")` or globbing any scheme whose registered reader reports isGlobbable() == false; the error carries the URI and its scheme.","commonSituations":"Trying to glob remote HTTP resources, globbing custom external-reader schemes that only support single reads, assuming URL wildcard expansion works like on a filesystem.","solutions":["Glob only local filesystem/module-path URIs; list remote resources explicitly instead.","Enumerate the remote resources another way (an index file, directory listing API) and import each explicitly.","If you own a custom reader, implement glob support (isGlobbable + listing) rather than globbing over it.","Check the scheme in the error message to confirm which reader rejected the glob."],"exampleFix":"// before\nread*(\"https://example.com/configs/*.pkl\")\n// after\nfor (name in listOf(\"a\", \"b\")) {\n  read(\"https://example.com/configs/\\(name).pkl\")\n}","handlingStrategy":"validation","validationCode":"const GLOBBABLE_SCHEMES = ['file', 'module', 'projectresource', 'package']\nconst isGlobbableUri = (u) => GLOBBABLE_SCHEMES.includes(new URL(u).scheme ?? 'file')","typeGuard":"const canGlob = (uri) => !/^[a-z]+:\\/\\//.test(uri) || GLOBBABLE_SCHEMES.includes(uri.split('://')[0])","tryCatchPattern":"try {\n  readGlob(pattern)\n} catch (e) {\n  if (e.code === 'cannotGlobUri') enumerateResourcesExplicitly(e.data.uri)\n  else throw e\n}","preventionTips":["Only glob local/module-path resources","Fetch remote resource lists via an index instead of wildcards","Check the URI scheme before using `read*`"],"tags":["glob","uri","scheme","unsupported"],"backgroundTag":"unsupported-operation","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"}