apple/pkl · error

invalidGlobPattern

invalidGlobPattern

Error message

invalidGlobPattern

What it means

A glob import URI contained a malformed glob pattern. When GlobResolver rejects the pattern it throws InvalidGlobPatternException, which CommandSpecParser converts into an `invalidGlobPattern` eval error carrying the URI string plus the invalidity reason as a hint.

Source

Thrown at pkl-core/src/main/java/org/pkl/core/runtime/CommandSpecParser.java:1210

            .build();
      }
      var resolvedElements =
          GlobResolver.resolveGlob(securityManager, globModuleKey, null, null, uriString);

      var builder = new VmObjectBuilder(resolvedElements.size());
      for (var entry : resolvedElements.entrySet()) {
        var moduleKey = moduleResolver.resolve(entry.getValue().uri());
        builder.addEntry(entry.getKey(), language.loadModule(moduleKey));
      }
      return builder.toMapping(resolvedElements);
    } catch (IOException e) {
      throw exceptionBuilder().evalError("ioErrorResolvingGlob", importUri).withCause(e).build();
    } catch (ExternalReaderProcessException e) {
      throw exceptionBuilder().evalError("externalReaderFailure").withCause(e).build();
    } catch (SecurityManagerException e) {
      throw exceptionBuilder().withCause(e).build();
    } catch (InvalidGlobPatternException e) {
      throw exceptionBuilder()
          .evalError("invalidGlobPattern", uriString)
          .withHint(e.getMessage())
          .build();
    }
  }

  // endregion
  // region utilities

  private static @Nullable String exportNullableString(VmObjectLike value, Object key) {
    var result = VmValue.export(VmUtils.readMember(value, key));
    return result instanceof PNull ? null : (String) result;
  }

  /** Check a value and its parents to see if any assign/amend the given property */
  private void checkPropertyIsUndefined(VmTyped value, Identifier name) {
    var member = VmUtils.findMember(value, name);
    if (member == null) return;

View on GitHub (pinned to f3efcbfc9b)

Solutions

  1. Read the error hint — it states exactly what part of the pattern is invalid.
  2. Fix the pattern syntax: balance [] and {}, use `**` only as a whole path segment, use forward slashes.
  3. Test the pattern locally with a glob tool matching Pkl's syntax before adding it to config.
  4. Escape literal special characters ([, ], {, }, *, ?) if they are meant literally.

Example fix

// before
x = import("glob:configs/[a-z/*.pkl")

// after
x = import("glob:configs/[a-z]/*.pkl")
Defensive patterns

Strategy: validation

Validate before calling

// quick pattern sanity check before committing
// balance of [], {}, and no stray '**/' misuse
function looksLikeValidGlob(p) = p.countOf("[") == p.countOf("]") && p.countOf("{") == p.countOf("}")

Prevention

When it happens

Trigger: import("glob:...") with a pattern that the glob parser rejects — e.g. unbalanced brackets, an illegal `**` placement, or characters not permitted in the pattern syntax for the target scheme.

Common situations: Hand-writing glob patterns with typos like `[a-z` or `{` after a shell/regex conversion; patterns copied from a tool using different glob semantics; Windows path separators mixed into the pattern.

Related errors


AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08). Data as JSON: /api/errors/ef74b6aef6a6eb90. Report an issue: GitHub.