{"record":{"id":"511fe94740e2b6ef","repo":"apple/pkl","slug":"invalidresourceuri","errorCode":"invalidResourceUri","errorMessage":"invalidResourceUri","messagePattern":"invalidResourceUri","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/runtime/ResourceManager.java","lineNumber":83,"sourceCode":"          .withLocation(readNode)\n          .evalError(\"noResourceReaderRegistered\", resourceUri.getScheme())\n          .build();\n    }\n    return reader;\n  }\n\n  public Optional<Object> doRead(ResourceReader reader, URI uri, @Nullable Node readNode) {\n    Optional<Object> resource;\n    try {\n      resource = reader.read(uri);\n    } catch (IOException e) {\n      throw new VmExceptionBuilder()\n          .evalError(\"ioErrorReadingResource\", uri)\n          .withCause(e)\n          .withOptionalLocation(readNode)\n          .build();\n    } catch (URISyntaxException e) {\n      throw new VmExceptionBuilder()\n          .evalError(\"invalidResourceUri\", uri)\n          .withHint(e.getReason())\n          .withOptionalLocation(readNode)\n          .build();\n    } catch (SecurityManagerException\n        | PackageLoadError\n        | HttpClientException\n        | ExternalReaderProcessException e) {\n      throw new VmExceptionBuilder().withCause(e).withOptionalLocation(readNode).build();\n    }\n    return resource;\n  }\n\n  @TruffleBoundary\n  public Optional<Object> read(URI resourceUri, @Nullable Node readNode) {\n    return resources.computeIfAbsent(\n        resourceUri.normalize(),\n        (uri) -> {","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/runtime/ResourceManager.java#L65-L101","documentation":"If ResourceReader.read(uri) throws URISyntaxException while parsing the resource URI, ResourceManager.doRead() converts it to eval error 'invalidResourceUri' with the URI and the parser's reason as a hint.","triggerScenarios":"doRead() called with a syntactically invalid URI (illegal characters, bad percent-encoding) that the reader re-parses strictly, throwing URISyntaxException.","commonSituations":"read() calls with unescaped spaces or stray '%' in file/http resource paths; interpolated resource URIs where an unexpected value breaks URI syntax.","solutions":["Percent-encode invalid characters in the resource URI (e.g. spaces as %20).","Validate/normalize the URI string before passing it to read().","Read the error's hint — it states the exact URI parsing problem."],"exampleFix":"// before\nread(\"file:///my docs/data.txt\")\n// after\nread(\"file:///my%20docs/data.txt\")","handlingStrategy":"validation","validationCode":"try { new URI(resourceUriString); } catch (URISyntaxException e) { /* fix encoding before read() */ }","typeGuard":null,"tryCatchPattern":"catch (VmException e) { if (\"invalidResourceUri\".equals(e.getCode())) { /* use e hint to explain bad URI */ } }","preventionTips":["Percent-encode dynamic path segments in resource URIs.","Never concatenate unvalidated user input into a resource URI."],"tags":["uri","resource-read","syntax"],"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-17T20:17:13.540Z"}