PklBugException when given a file: URI with a host #193

Open
opened 2025-12-30 01:21:59 +01:00 by adam · 1 comment
Owner

Originally created by @bioball on GitHub (Aug 6, 2024).

Pkl currently hard-fails if given a file: URI with a host set.

For example:

pkl eval file://example.com/bar/baz.pkl

Produces:

An unexpected error has occurred. Would you mind filing a bug report?

We should either support remote files, or throw a meaningful error here.

Originally created by @bioball on GitHub (Aug 6, 2024). Pkl currently hard-fails if given a `file:` URI with a host set. For example: ``` pkl eval file://example.com/bar/baz.pkl ``` Produces: ``` An unexpected error has occurred. Would you mind filing a bug report? ``` We should either support remote files, or throw a meaningful error here.
adam added the bug label 2025-12-30 01:21:59 +01:00
Author
Owner

@Carpe-Wang commented on GitHub (Aug 18, 2024):

@bioball Hi, may I try to fix the bug? I will change the code to like below

 public static URL toUrl(URI uri) throws IOException {
   try {
     if ("file".equalsIgnoreCase(uri.getScheme()) && uri.getHost() != null) {
       throw new UnsupportedOperationException("Remote file URIs are not supported: " + uri);
     }
     return uri.toURL();
   } catch (Error e) {
     // best we can do for now
     // rely on caller to provide context, e.g., the requested module URI
     if (e.getClass().getName().equals("com.oracle.svm.core.jdk.UnsupportedFeatureError")) {
       throw new IOException("Unsupported protocol: " + uri.getScheme());
     }
     throw e;
   }
 }

If assign the bug to me, I will try my best to support remote files by download the file or other ways.

@Carpe-Wang commented on GitHub (Aug 18, 2024): @bioball Hi, may I try to fix the bug? I will change the code to like below ```java public static URL toUrl(URI uri) throws IOException { try { if ("file".equalsIgnoreCase(uri.getScheme()) && uri.getHost() != null) { throw new UnsupportedOperationException("Remote file URIs are not supported: " + uri); } return uri.toURL(); } catch (Error e) { // best we can do for now // rely on caller to provide context, e.g., the requested module URI if (e.getClass().getName().equals("com.oracle.svm.core.jdk.UnsupportedFeatureError")) { throw new IOException("Unsupported protocol: " + uri.getScheme()); } throw e; } } ``` If assign the bug to me, I will try my best to support remote files by download the file or other ways.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#193