Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: escape glob-special characters in directory paths#984

Merged
TabishB merged 4 commits into
Fission-AI:mainfrom
furaul:fix/glob-parentheses-974
Apr 21, 2026
Merged

fix: escape glob-special characters in directory paths#984
TabishB merged 4 commits into
Fission-AI:mainfrom
furaul:fix/glob-parentheses-974

Conversation

@furaul
Copy link
Copy Markdown
Contributor

@furaul furaul commented Apr 17, 2026

Summary

  • Escape parentheses and square brackets in the directory portion of glob patterns before passing to fast-glob, so they are treated as literal path characters instead of extglob syntax
  • Add escapeGlobPath() helper that targets only () and [] — characters proven to break fast-glob/picomatch matching in filesystem paths
  • Add 4 test cases covering parentheses, square brackets, curly braces, and non-glob generates with special-character directories

Test plan

  • All 12 existing + new tests pass (vitest run test/core/artifact-graph/outputs.test.ts)
  • Verified glob patterns resolve correctly when directory contains (), [], {}
  • Verified non-glob generates (e.g. proposal.md) still works via fs.statSync path

Closes #974

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Artifact output resolution correctly handles directory names containing glob-special characters (parentheses, brackets, braces).
    • Glob pattern matching and file existence checks now succeed for artifacts in directories with those naming patterns.
    • Resolved behavior for literal (non-glob) outputs in such directories so canonical files are found.
  • Tests

    • Added test coverage for directories with glob-special characters to ensure correctness.

Parentheses and square brackets in project directory paths broke
fast-glob matching, causing glob-based artifact outputs to silently
return empty results. Escape these characters in the directory portion
before passing to fast-glob, preserving glob semantics in the generates
pattern.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: be67f35e-abe4-483f-bd08-0de52e52d8f6

📥 Commits

Reviewing files that changed from the base of the PR and between e07b912 and cba5a5c.

📒 Files selected for processing (2)
  • src/core/artifact-graph/outputs.ts
  • test/core/artifact-graph/outputs.test.ts
✅ Files skipped from review due to trivial changes (1)
  • test/core/artifact-graph/outputs.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/core/artifact-graph/outputs.ts

📝 Walkthrough

Walkthrough

Adjusts artifact output resolution: non-glob generates now computes and uses fullPath for existence checks and canonicalization; glob generates use the raw generates for POSIX normalization and invokes fast-glob with { cwd: changeDir, onlyFiles: true, absolute: true }. Tests added for base directories containing glob-special characters.

Changes

Cohort / File(s) Summary
Artifact output resolution
src/core/artifact-graph/outputs.ts
Refactored resolve logic: compute fullPath only for non-glob outputs and use it for fs checks/canonicalization; for glob outputs, normalize using toPosixPath(generates) and call fast-glob with cwd: changeDir, onlyFiles: true, absolute: true. Dedupe, canonicalize, and sort matches as before.
Tests for special-character dirs
test/core/artifact-graph/outputs.test.ts
Added tests validating resolution and existence for artifact bases whose directory names contain glob-special characters ((), [], {}, and brace-like syntax), for both glob and literal outputs.

Sequence Diagram(s)

(Skipped — changes are local resolution logic and tests, not multi-component sequential flows.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • alfred-openspec

Poem

"I’m a rabbit in the code, with nimble little paws,
I hop past brackets, braces, parens—defend against their claws.
Globs no longer tangle me, I sniff the right path true,
Files found, tests passing—happy hops from me to you! 🐇"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: escaping glob-special characters in directory paths to fix the artifact output resolution issue.
Linked Issues check ✅ Passed The changes directly address issue #974 by handling glob-special characters in directory paths to prevent glob-matching failures and incorrect artifact resolution.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing glob-special character handling in artifact output resolution, with no unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/core/artifact-graph/outputs.ts (1)

13-21: Residual edge cases: brace expansion and leading ! in directory names.

The targeted ()[] escape covers the reported bug and keeps the implementation minimal, which is good. The doc comment correctly notes that isolated {...} does not break picomatch (brace expansion requires , or .. inside), which is why the {workspace} test passes. However, directory names that actually contain brace-expansion syntax (e.g. foo{a,b}) or start with ! (negation) will still misbehave. If you want to close that gap now, escaping {, }, and a leading ! on each path segment would cover the remaining picomatch metacharacters without changing behavior for the existing tests. Otherwise, the current scope is a reasonable, bug-focused fix.

picomatch metacharacters that must be escaped in literal filesystem paths (parentheses brackets braces negation)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/core/artifact-graph/outputs.ts` around lines 13 - 21, escapeGlobPath
currently only escapes parentheses and square brackets which leaves
brace-expansion sequences and leading negation chars unescaped; update
escapeGlobPath to also escape '{' and '}' and ensure any path segment that
begins with '!' has that leading '!' escaped (or prefixed) so picomatch won't
treat it as negation—locate the escapeGlobPath function and modify its
replacement logic to handle braces and to process each path segment to escape a
leading '!' while preserving existing behavior for other characters.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/core/artifact-graph/outputs.ts`:
- Around line 13-21: escapeGlobPath currently only escapes parentheses and
square brackets which leaves brace-expansion sequences and leading negation
chars unescaped; update escapeGlobPath to also escape '{' and '}' and ensure any
path segment that begins with '!' has that leading '!' escaped (or prefixed) so
picomatch won't treat it as negation—locate the escapeGlobPath function and
modify its replacement logic to handle braces and to process each path segment
to escape a leading '!' while preserving existing behavior for other characters.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 302138ad-1f4e-45cd-bab0-8ac3dcd37153

📥 Commits

Reviewing files that changed from the base of the PR and between f529b25 and e07b912.

📒 Files selected for processing (2)
  • src/core/artifact-graph/outputs.ts
  • test/core/artifact-graph/outputs.test.ts

@TabishB TabishB self-requested a review as a code owner April 21, 2026 15:31
@TabishB TabishB added this pull request to the merge queue Apr 21, 2026
Merged via the queue into Fission-AI:main with commit 7a39e88 Apr 21, 2026
9 checks passed
seanmars pushed a commit to seanmars/OpenSpec that referenced this pull request Apr 27, 2026
* fix: escape glob-special chars in directory paths (Fission-AI#974)

Parentheses and square brackets in project directory paths broke
fast-glob matching, causing glob-based artifact outputs to silently
return empty results. Escape these characters in the directory portion
before passing to fast-glob, preserving glob semantics in the generates
pattern.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix: use cwd for artifact output globs

---------

Co-authored-by: furao <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
Co-authored-by: Tabish Bidiwale <[email protected]>
Co-authored-by: TabishB <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parenthesis on directory and filenames break openspec artifact check

2 participants