{"record":{"id":"79856ca032e8e5d6","repo":"apple/pkl","slug":"ioerrorreadingresource-79856c","errorCode":"ioErrorReadingResource","errorMessage":"I/O error reading resource `{0}`.","messagePattern":"I/O error reading resource `(.+?)`\\.","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/expression/unary/AbstractReadNode.java","lineNumber":73,"sourceCode":"    var resolvedUri = resolveResource(currentModule, resourceUri);\n    return context.getResourceManager().read(resolvedUri, readNode).orElse(null);\n  }\n\n  private URI resolveResource(ModuleKey moduleKey, String resourceUri) {\n    var parsedUri = parseUri(resourceUri);\n    var context = VmContext.get(this);\n    URI resolvedUri;\n    try {\n      resolvedUri = IoUtils.resolve(context.getSecurityManager(), moduleKey, parsedUri);\n    } catch (FileNotFoundException e) {\n      throw exceptionBuilder().evalError(\"cannotFindResource\", resourceUri).build();\n    } catch (URISyntaxException e) {\n      throw exceptionBuilder()\n          .evalError(\"invalidResourceUri\", resourceUri)\n          .withHint(e.getReason())\n          .build();\n    } catch (IOException e) {\n      throw exceptionBuilder()\n          .evalError(\"ioErrorReadingResource\", resourceUri)\n          .withHint(e.getMessage())\n          .build();\n    } catch (PackageLoadError | SecurityManagerException e) {\n      throw exceptionBuilder().withCause(e).build();\n    } catch (ExternalReaderProcessException e) {\n      throw exceptionBuilder().evalError(\"externalReaderFailure\").withCause(e).build();\n    }\n\n    if (!resolvedUri.isAbsolute()) {\n      throw exceptionBuilder().evalError(\"cannotHaveRelativeResource\", moduleKey.getUri()).build();\n    }\n    return resolvedUri;\n  }\n}\n","sourceCodeStart":55,"sourceCodeEnd":89,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/expression/unary/AbstractReadNode.java#L55-L89","documentation":"Pkl throws this when reading a resource fails with a general IOException that is not a simple FileNotFoundException — the URI resolved but the underlying transport (filesystem, HTTP, package loader) hit an I/O problem. The original exception message is attached as a hint.","triggerScenarios":"Calling `read()` where the target exists conceptually but I/O fails: network errors during HTTP fetch, permission errors on open, connection reset mid-transfer, directory read attempts.","commonSituations":"Offline environment or proxy blocking an https resource read; filesystem permissions deny access; remote host unreachable; reading a path that is a directory rather than a file.","solutions":["Read the hint (IOException message) to identify the underlying transport failure.","Check network connectivity, proxy settings, and that the remote host is reachable.","Verify filesystem permissions on the target file.","Ensure the URI points to a file, not a directory, and that any required services are running."],"exampleFix":"// before\nx = read(\"https://internal.corp/api/config\")  // blocked by proxy\n// after\nx = read(\"https://proxy-adjusted-host/api/config\") // or fix proxy env: HTTPS_PROXY","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Host-side (Java) around Pkl evaluation or reader setup:\ntry {\n  result = evaluator.evaluateOutputSource(moduleSource);\n} catch (PklException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"I/O error reading resource\")) {\n    // log hint, check connectivity/permissions, retry with backoff if transient\n  } else throw e;\n}","preventionTips":["Check network/proxy/VPN availability before evaluations that read remote resources.","Ensure service accounts have read permission on referenced files.","Point resource URIs at files, not directories."],"tags":["io","network","resource","pkl"],"backgroundTag":"file-read-failed","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"}