Skip to content

Glob matcher passes regex metacharacters through: '+' throws, '(…)' and '?' mismatch, bare '**' misses nested paths #178

Closed

Description

@FredApps

What went wrong?

DiffCI crashed or printed an error

DiffCI version

core main 40aa308 (src/research/baseline/matcher.ts, exported as @diffci.com/core/research/baseline/matcher)

Command you ran

import { matchesAny } from "./src/research/baseline/matcher.ts";
for (const [path, glob] of [
  ["app/(shop)/page.tsx", "app/(shop)/**"],   // Next.js route group
  ["app/[id]/page.tsx", "app/\\[id\\]/*"],
  ["a/b/c.js", "**"],
  ["a/b/c.js", "**.js"],
  ["src/a.ts", "src/?.ts"],
  ["c++/x.cc", "c++/*"],
]) console.log(path, glob, matchesAny(path, [glob]));

Environment

Linux, Node 24

Output

app/(shop)/page.tsx app/(shop)/** false
app/[id]/page.tsx app/\[id\]/* false
a/b/c.js ** false
a/b/c.js **.js false
src/a.ts src/?.ts false
SyntaxError: Invalid regular expression: /^c++/[^/]*$/: Nothing to repeat
    at regexFrom (src/research/baseline/matcher.ts:25:10)

Cause

regexFrom (src/research/baseline/matcher.ts:13-26) escapes only \ and . before turning the glob into a regular expression. Everything else goes through as regex syntax:

  • (, ), |, ^ and $ act as regex operators, so the literal route group (shop) never matches;
  • + throws;
  • ? becomes a quantifier instead of "one character";
  • the \ that escapes a glob character is itself escaped, so \[id\] can't name a literal bracket.

A ** that isn't next to a / (**, **.js) falls through to the single-* rule, so it never crosses a directory.

src/planner/planner.ts:13-46 has an identical copy, which DefaultCIPlanner uses for inputPatterns. Today the patterns come from built-in defaults that avoid these characters. But workflow path filters (#177) and caller-supplied createTaskRegistry patterns don't.

What you expected

Glob semantics. * and ? stay within a segment, ** crosses segments, {a,b} and [...] work as in globs, \ escapes the next character, and every other character is literal. A pattern never throws.

Activity

  1. added a commit that references this issue on Nov 18, 2026
    7d98c08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions