[codex] fix sandbox glob_files recursive patterns#1684
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR fixes a real bug: glob_files in sandbox mode advertised support for recursive patterns like **/*.java, but the implementation forwarded the pattern directly to find -name, which only matches the filename portion. The fix correctly strips the leading **/ prefix since find already performs recursive directory traversal. The change is minimal, null-safe, and well-tested with a new BaseSandboxFilesystemTest using a clean fake-sandbox design. One minor symmetry observation regarding the sibling grep method is noted below.
| public GlobResult glob(RuntimeContext runtimeContext, String pattern, String path) { | ||
| String escapedPath = FilesystemUtils.shellQuote(path != null ? path : "/"); | ||
| String escapedPattern = FilesystemUtils.shellQuote(pattern); | ||
| String findNamePattern = |
There was a problem hiding this comment.
[nit] Symmetry note: the sibling grep() method (line ~282) passes its glob parameter directly to grep --include= without the same **/ stripping. GNU grep's --include also matches only the filename portion, so grep_files with **/*.java would silently return no matches — the same bug this PR fixes for glob_files. Consider applying the same normalization in a follow-up, or extracting a shared helper like stripRecursivePrefix(String).
|
|
||
| private static final RuntimeContext RT = RuntimeContext.empty(); | ||
|
|
||
| @Test |
There was a problem hiding this comment.
[praise] Nice test design — capturing the generated command string and asserting it directly is the right approach for testing shell-command delegation. The FakeSandboxFilesystem stub is minimal and focused.
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR fixes a real bug: glob_files in sandbox mode advertised support for recursive patterns like **/*.java, but the implementation forwarded the pattern directly to find -name, which only matches the filename portion. The fix correctly strips the leading **/ prefix since find already performs recursive directory traversal. The change is minimal, null-safe, and well-tested with a new BaseSandboxFilesystemTest using a clean fake-sandbox design. One minor symmetry observation regarding the sibling grep method is noted below.
| public GlobResult glob(RuntimeContext runtimeContext, String pattern, String path) { | ||
| String escapedPath = FilesystemUtils.shellQuote(path != null ? path : "/"); | ||
| String escapedPattern = FilesystemUtils.shellQuote(pattern); | ||
| String findNamePattern = |
There was a problem hiding this comment.
[nit] Symmetry note: the sibling grep() method (line ~282) passes its glob parameter directly to grep --include= without the same **/ stripping. GNU grep's --include also matches only the filename portion, so grep_files with **/*.java would silently return no matches — the same bug this PR fixes for glob_files. Consider applying the same normalization in a follow-up, or extracting a shared helper like stripRecursivePrefix(String).
|
|
||
| private static final RuntimeContext RT = RuntimeContext.empty(); | ||
|
|
||
| @Test |
There was a problem hiding this comment.
[praise] Nice test design — capturing the generated command string and asserting it directly is the right approach for testing shell-command delegation. The FakeSandboxFilesystem stub is minimal and focused.
Summary
**/in sandboxglob()before passing the pattern tofind -nameglob_filescalls like**/*.mdRoot Cause
The
glob_filestool description advertises recursive patterns such as**/*.java, butBaseSandboxFilesystem.glob()forwarded that pattern directly tofind -name.find -namematches the filename portion only, so the leading**/caused sandbox-backed recursive glob calls to return no matches.Validation
mvn -pl agentscope-harness -am -Dtest=BaseSandboxFilesystemTest,FilesystemGlobTest test