[PR #1087] [MERGED] Treat opaque file URIs as errors #882

Closed
opened 2025-12-30 01:27:33 +01:00 by adam · 0 comments
Owner

📋 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: mainHead: invalid-file-uri


📝 Commits (2)

📊 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.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.


🔄 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>
adam added the pull-request label 2025-12-30 01:27:33 +01:00
adam closed this issue 2025-12-30 01:27:33 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#882