apple/pkl · error · URISyntaxException
missingAuthorityInPackageUri
missingAuthorityInPackageUri
Error message
missingAuthorityInPackageUri
What it means
Thrown by the PackageUri constructor when the URI has an acceptable scheme but no authority component. A package URI must carry an authority (the registry/project host), e.g. 'package://example.com/...'; 'package:/path' or 'package:path' is invalid.
Source
Thrown at pkl-core/src/main/java/org/pkl/core/packages/PackageUri.java:56
}
public PackageUri(String baseUri) throws URISyntaxException {
this(new URI(baseUri));
}
public PackageUri(URI uri) throws URISyntaxException {
if (uri.isOpaque()) {
throw new URISyntaxException(
uri.toString(), ErrorMessages.create("invalidModuleUriMissingSlash", uri, "package"));
}
var scheme = uri.getScheme();
if (scheme == null || !(scheme.equals("package") || scheme.equals("projectpackage"))) {
throw new URISyntaxException(
uri.toString(), ErrorMessages.create("invalidSchemeInPackageUri", scheme));
}
var authority = uri.getAuthority();
if (authority == null || authority.isEmpty()) {
throw new URISyntaxException(
uri.toString(), ErrorMessages.create("missingAuthorityInPackageUri", uri));
}
var path = uri.getPath();
if (path == null || path.isEmpty()) {
throw new URISyntaxException(
uri.toString(), ErrorMessages.create("missingPathInPackageUri", uri));
}
// reject `..` segments, percent-encoded or not
for (var segment : path.split("/", -1)) {
if (segment.equals("..")) {
throw new URISyntaxException(
uri.toString(), ErrorMessages.create("invalidRelativePathInPackageUri"));
}
}
var versionIdx = path.lastIndexOf('@');
if (versionIdx == -1) {
throw new URISyntaxException(
uri.toString(), ErrorMessages.create("missingVersionInPackageUri", path));View on GitHub (pinned to f3efcbfc9b)
Solutions
- Add the registry/project authority after the scheme: package://example.com/my-pkg@1.2.3
- Check that you use the '//' delimiter so URI parsing yields a non-empty authority
- Validate the package URI against the value published in the dependency's PklProject
Example fix
// before
var uri = URI.create("package:///my-pkg@1.2.3");
var pkg = new PackageUri(uri);
// after
var uri = URI.create("package://example.com/my-pkg@1.2.3");
var pkg = new PackageUri(uri); Defensive patterns
Strategy: validation
Validate before calling
boolean hasAuthority(URI uri) {
return uri.getAuthority() != null && !uri.getAuthority().isEmpty();
} Type guard
static boolean hasPackageAuthority(URI uri) {
return "package".equals(uri.getScheme()) && uri.getAuthority() != null && !uri.getAuthority().isEmpty();
} Try / catch
try {
var pkg = new PackageUri(uri);
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Package URI missing authority: " + uri, e);
} Prevention
- Include the registry host in every package URI
- Check for the '//' delimiter after the scheme
- Compare against the URI published in the package's PklProject
When it happens
Trigger: new PackageUri(uri) or PackageUtils.parsePackageUriWithoutChecksums where uri.getAuthority() returns null or the empty string, e.g. 'package:///foo@1.0.0' or 'package:foo@1.0.0'.
Common situations: Omitting the registry host when writing dependency URIs by hand; building URIs with URI.create that collapse an empty authority ('//'); copying URIs from docs and dropping the domain part.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- invalidSchemeInPackageUri
- missingPathInPackageUri
- invalidRelativePathInPackageUri
- missingVersionInPackageUri
- invalidPackageUriChecksum
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/321c239ed7eadeae.
Report an issue: GitHub.