Skip to content

Nested or escaped braces in rule, include and exclude patterns are split wrongly (**/*.{ts,{js,jsx}} drops .ts) #2097

Backlog

Description

@alex09x

OpenCodeReview Version

main d4f568f

Operating System

Linux (x86_64)

Installation Method

Built from source

LLM Provider

Not relevant (pattern matching runs before any LLM call)

Bug Description

expandBraces in internal/config/rules/system_rules.go splits a pattern at its first { and its first } before calling doublestar.Match. It is used by rules, include and exclude in rule.json and by the built-in path_rule_map. Two kinds of patterns break:

  • Nested groups. **/*.{ts,{js,jsx}} becomes **/*.ts}, **/*.{js} and **/*.jsx}, so only .js files match; .ts and .jsx files silently get no rule, are not included, or are not excluded.
  • Escaped braces. pages/\{id\}.ts (a literal {id} file name, as in file-based routing) is split as if it were a group and never matches pages/{id}.ts.

doublestar already reads both forms correctly when given the whole pattern.

Steps to Reproduce

In internal/config/rules:

f := &FileFilter{Include: []string{"**/*.{ts,{js,jsx}}"}}
f.IsUserIncluded("web/app.ts")     // false
f.IsUserIncluded("web/ui/App.jsx") // false
f.IsUserIncluded("web/app.js")     // true

g := &FileFilter{Include: []string{`pages/\{id\}.ts`}}
g.IsUserIncluded("pages/{id}.ts")  // false

The same split happens in IsUserExcluded, matchProjectRuleEntry and SystemRule.Resolve.

Expected Behavior

Brace groups match the same files as doublestar.Match on the unsplit pattern: web/app.ts, web/app.js and web/App.jsx for **/*.{ts,{js,jsx}}, and pages/{id}.ts for pages/\{id\}.ts.

Logs / Error Output

n/a

AI/LLM Disclosure

  • I didn't use AI/LLM to assist or generate the content above.

Additional Context

AI disclosure: used Claude Code (Claude Opus 5.5) while inspecting the codebase and writing this change. A PR with the fix is opened right after this issue.

Activity

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