{"record":{"id":"3feac4235251e670","repo":"apple/pkl","slug":"invalidglobnonhierarchicaluri","errorCode":"invalidGlobNonHierarchicalUri","errorMessage":"invalidGlobNonHierarchicalUri","messagePattern":"invalidGlobNonHierarchicalUri","errorType":"error_code","errorClass":"InvalidGlobPatternException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java","lineNumber":452,"sourceCode":"      }\n    }\n  }\n\n  /** Split a glob pattern into the base, non-wildcard parts, and the wildcard parts. */\n  private static Pair<String, String[]> splitGlobPatternIntoBaseAndWildcards(\n      ReaderBase reader, String globPattern, boolean hasAbsoluteGlob)\n      throws InvalidGlobPatternException {\n    var effectiveGlobPattern = globPattern;\n    var basePathSb = new StringBuilder();\n    if (hasAbsoluteGlob) {\n      var globUri = URI.create(globPattern);\n      if (reader.hasFragmentPaths()) {\n        effectiveGlobPattern = globUri.getFragment();\n        basePathSb.append(IoUtils.stripFragment(globUri)).append('#');\n      } else {\n        effectiveGlobPattern = globUri.getPath();\n        if (effectiveGlobPattern == null) {\n          throw new InvalidGlobPatternException(\n              ErrorMessages.create(\"invalidGlobNonHierarchicalUri\", globUri.getScheme()));\n        }\n        basePathSb.append(globUri.getScheme()).append(':');\n      }\n    }\n    var parts = effectiveGlobPattern.split(\"/\");\n    int i;\n\n    for (i = 0; i < parts.length; i++) {\n      var part = parts[i];\n      if (!isRegularPathPart(part)) {\n        break;\n      }\n      basePathSb.append(part).append('/');\n    }\n    return Pair.of(basePathSb.toString(), Arrays.copyOfRange(parts, i, parts.length));\n  }\n","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java#L434-L470","documentation":"When splitting a glob URI into a base path and wildcard parts, the resolver needs a hierarchical path component. If the URI has no fragment paths and getPath() returns null (typical for opaque, non-hierarchical URIs like mailto: or urn:), it cannot glob and throws invalidGlobNonHierarchicalUri, including the scheme in the message.","triggerScenarios":"Calling splitGlobPatternIntoBaseAndWildcards (via GlobResolver.splitPattern / glob resolution entry points) with a glob URI whose scheme defines no path, e.g. \"projectpartial:foo\" style opaque URIs or a scheme-registered reader without hierarchical paths.","commonSituations":"Misconfiguring a glob import with a custom/opaque scheme, typos in the URI scheme turning a hierarchical scheme into an unknown one, or using a reader that declares no fragment/path support.","solutions":["Use a hierarchical URI with a path for the glob (e.g. \"file:///path/dir/*.pkl\", \"https://host/path/*.pkl\")","Fix the URI scheme spelling so it resolves to the intended hierarchical scheme handler","If using a custom scheme, ensure the reader supports fragment/paths or provides a path"],"exampleFix":"// before\nimport \"myscheme:*.pkl\"\n// after\nimport \"file:///path/to/project/*.pkl\"","handlingStrategy":"validation","validationCode":"function isHierarchicalUri(uri) {\n  const u = new java.net.URI(uri); // or parse manually\n  return u.getScheme() != null && (u.getPath() != null || u.getFragment() != null);\n}","typeGuard":"const isGlobbable = (uri) => /^[a-z][a-z0-9+.-]*:/.test(uri) && uri.replace(/^[a-z][a-z0-9+.-]*:/, '').length > 0 && !/^(mailto|urn):/.test(uri);","tryCatchPattern":"try {\n  var parts = GlobResolver.splitPattern(globUri);\n} catch (InvalidGlobPatternException e) {\n  if (e.getMessage().contains(\"NonHierarchicalUri\")) throw new IllegalArgumentException(\"Glob needs a URI with a path: \" + globUri);\n  throw e;\n}","preventionTips":["Always give glob URIs a path component (scheme:path/... or scheme://host/path)","Verify the reader for the scheme supports hierarchical/fragment paths","Beware opaque schemes (mailto:, urn:) — they cannot be globbed"],"tags":["glob","uri","pkl"],"backgroundTag":"invalid-url","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}