Opaque file URIs are URIs whose scheme-specific part does not start with /.
For example, file:foo/bar.txt is an opaque URI.
Currently, this has the unintentional behavior of: look for file foo/bar.txt from the process working directory.
These are effectively dynamics imports; from a single import, we can't statically analyze what it resolves as.
This changes Pkl's behavior so that these URIs are treated as errors.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/apple/pkl/pull/1087
**Author:** [@bioball](https://github.com/bioball)
**Created:** 6/3/2025
**Status:** ✅ Merged
**Merged:** 6/3/2025
**Merged by:** [@bioball](https://github.com/bioball)
**Base:** `main` ← **Head:** `invalid-file-uri`
---
### 📝 Commits (2)
- [`38dec64`](https://github.com/apple/pkl/commit/38dec64fe08c9031cde9ee944949b9721c6754d0) Treat opaque file URIs as errors
- [`3862682`](https://github.com/apple/pkl/commit/38626829b0529978b2dff1989ab1bb3c503bcecb) Polish
### 📊 Changes
**16 files changed** (+109 additions, -9 deletions)
<details>
<summary>View changed files</summary>
📝 `pkl-core/src/main/java/org/pkl/core/ast/expression/unary/ImportGlobNode.java` (+2 -2)
📝 `pkl-core/src/main/java/org/pkl/core/module/ModuleKeyFactories.java` (+1 -1)
📝 `pkl-core/src/main/java/org/pkl/core/module/ModuleKeys.java` (+15 -2)
📝 `pkl-core/src/main/java/org/pkl/core/project/ProjectPackager.java` (+2 -2)
📝 `pkl-core/src/main/java/org/pkl/core/resource/ResourceReaders.java` (+7 -1)
📝 `pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java` (+6 -1)
📝 `pkl-core/src/main/java/org/pkl/core/util/IoUtils.java` (+6 -0)
📝 `pkl-core/src/main/resources/org/pkl/core/errorMessages.properties` (+7 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/input/errors/invalidFileUri1.pkl` (+1 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/input/errors/invalidFileUri2.pkl` (+1 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/input/errors/invalidFileUri3.pkl` (+1 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/input/errors/invalidFileUri4.pkl` (+9 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/output/errors/invalidFileUri1.err` (+13 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/output/errors/invalidFileUri2.err` (+12 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/output/errors/invalidFileUri3.err` (+13 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/output/errors/invalidFileUri4.err` (+13 -0)
</details>
### 📄 Description
Opaque file URIs are URIs whose scheme-specific part does not start with `/`.
For example, `file:foo/bar.txt` is an opaque URI.
Currently, this has the unintentional behavior of: look for file `foo/bar.txt` from the process working directory.
These are effectively dynamics imports; from a single import, we can't statically analyze what it resolves as.
According to RFC-8089, File URIs must have paths that start with `/`. So, these are actually _not valid URIs_.
See the grammar defined in https://datatracker.ietf.org/doc/html/rfc8089#section-2
This changes Pkl's behavior so that these URIs are treated as errors.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/1087
Author: @bioball
Created: 6/3/2025
Status: ✅ Merged
Merged: 6/3/2025
Merged by: @bioball
Base:
main← Head:invalid-file-uri📝 Commits (2)
38dec64Treat opaque file URIs as errors3862682Polish📊 Changes
16 files changed (+109 additions, -9 deletions)
View changed files
📝
pkl-core/src/main/java/org/pkl/core/ast/expression/unary/ImportGlobNode.java(+2 -2)📝
pkl-core/src/main/java/org/pkl/core/module/ModuleKeyFactories.java(+1 -1)📝
pkl-core/src/main/java/org/pkl/core/module/ModuleKeys.java(+15 -2)📝
pkl-core/src/main/java/org/pkl/core/project/ProjectPackager.java(+2 -2)📝
pkl-core/src/main/java/org/pkl/core/resource/ResourceReaders.java(+7 -1)📝
pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java(+6 -1)📝
pkl-core/src/main/java/org/pkl/core/util/IoUtils.java(+6 -0)📝
pkl-core/src/main/resources/org/pkl/core/errorMessages.properties(+7 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/errors/invalidFileUri1.pkl(+1 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/errors/invalidFileUri2.pkl(+1 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/errors/invalidFileUri3.pkl(+1 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/errors/invalidFileUri4.pkl(+9 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/errors/invalidFileUri1.err(+13 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/errors/invalidFileUri2.err(+12 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/errors/invalidFileUri3.err(+13 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/errors/invalidFileUri4.err(+13 -0)📄 Description
Opaque file URIs are URIs whose scheme-specific part does not start with
/.For example,
file:foo/bar.txtis an opaque URI.Currently, this has the unintentional behavior of: look for file
foo/bar.txtfrom the process working directory.These are effectively dynamics imports; from a single import, we can't statically analyze what it resolves as.
According to RFC-8089, File URIs must have paths that start with
/. So, these are actually not valid URIs.See the grammar defined in https://datatracker.ietf.org/doc/html/rfc8089#section-2
This changes Pkl's behavior so that these URIs are treated as errors.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.