{"record":{"id":"3e557820fb230050","repo":"apple/pkl","slug":"invalidusageofprojectfromnonfileuri","errorCode":"invalidUsageOfProjectFromNonFileUri","errorMessage":"invalidUsageOfProjectFromNonFileUri","messagePattern":"invalidUsageOfProjectFromNonFileUri","errorType":"error_code","errorClass":"PackageLoadError","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/project/Project.java","lineNumber":473,"sourceCode":"   *\n   * @since 0.32.0\n   */\n  public PklEvaluatorSettings getResolvedEvaluatorSettings() {\n    return resolvedEvaluatorSettings;\n  }\n\n  public URI getProjectFileUri() {\n    return projectFileUri;\n  }\n\n  public List<Path> getTests() {\n    return tests.stream()\n        .map(\n            (it) -> {\n              try {\n                return Path.of(it);\n              } catch (FileSystemNotFoundException e) {\n                throw new PackageLoadError(\"invalidUsageOfProjectFromNonFileUri\");\n              }\n            })\n        .collect(Collectors.toList());\n  }\n\n  @Override\n  public boolean equals(@Nullable Object o) {\n    if (this == o) {\n      return true;\n    }\n    if (o == null || getClass() != o.getClass()) {\n      return false;\n    }\n    Project project = (Project) o;\n    return Objects.equals(pkg, project.pkg)\n        && dependencies.equals(project.dependencies)\n        && evaluatorSettings.equals(project.evaluatorSettings)\n        && resolvedEvaluatorSettings.equals(project.resolvedEvaluatorSettings)","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/project/Project.java#L455-L491","documentation":"Project.getTests() maps each test entry to a filesystem Path. If a test entry's URI is not backed by the default filesystem (e.g. it comes from a non-file URI such as a package/jar URI), Path.of throws FileSystemNotFoundException, which is converted to PackageLoadError('invalidUsageOfProjectFromNonFileUri'). The project's tests are only usable when loaded from the local filesystem.","triggerScenarios":"Calling project.getTests() on a Project whose URI (and thus its test entries) is not a file: URI — e.g. a project loaded from inside a package or another non-file scheme.","commonSituations":"Running tests against a project resolved from a remote package instead of a checked-out local copy; embedding Pkl where projects come from virtual filesystems.","solutions":["Check out / materialize the project on the local filesystem before calling getTests()","Verify project.getProjectFileUri().getScheme() equals \"file\" before invoking getTests()","Catch PackageLoadError and fall back to a filesystem-backed copy of the project"],"exampleFix":"// before\nvar tests = project.getTests();\n// after\nif (!\"file\".equals(project.getProjectFileUri().getScheme())) {\n  throw new IllegalStateException(\"tests require a filesystem-backed project\");\n}\nvar tests = project.getTests();","handlingStrategy":"type-guard","validationCode":"if (!\"file\".equals(project.getProjectFileUri().getScheme())) throw new IllegalStateException(\"getTests requires a filesystem-backed project\");","typeGuard":"boolean isFileBacked(Project p) { return p.getProjectFileUri().getScheme().equals(\"file\"); }","tryCatchPattern":"try { return project.getTests(); } catch (PackageLoadError e) { // materialize project locally and retry }","preventionTips":["Only call getTests() on locally checked-out projects","Check URI scheme before filesystem operations","Materialize package-resolved projects into a temp dir for testing"],"tags":["filesystem","projects","testing"],"backgroundTag":"unsupported-operation","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}