Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bioball opened this issue Aug 6, 2024 · 1 comment · May be fixed by #629
Open

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

bioball opened this issue Aug 6, 2024 · 1 comment · May be fixed by #629
Labels
bug Something isn't working

Comments

@bioball
Copy link
Contributor

bioball commented 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.

@bioball bioball added the bug Something isn't working label Aug 6, 2024
@Carpe-Wang
Copy link

@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 Carpe-Wang linked a pull request Aug 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants