You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Java grep fallback searches sibling files for a single-file path #4141
When ripgrep is unavailable, LocalFilesystem.grep searches the parent directory even when path names one file. Matches from sibling files and nested directories are returned alongside that file. A file with no matches can also appear to have matches because another file contains the pattern.
Actual: matches from both /target.txt and /other.txt.
Expected behavior
A file path searches that file only. A directory path still searches recursively. This should not depend on whether ripgrep is installed.
Error messages
No exception is raised; the search succeeds with unrelated matches.
Environment
AgentScope Java main at c8875287 (2.1.0-SNAPSHOT)
Java 17, Windows 11
Additional context
javaSearch sets its walk root to basePath.getParent() for file inputs. Files.walk(basePath) already handles both files and directories, so the parent expansion is unnecessary.
I reproduced this through the public grep method in a JVM whose PATH excludes ripgrep. Six targeted tests on the original code report four failures for file scope and two passes for directory recursion/glob filtering. The tests use real temporary files and force only the ripgrep launch to fail.
The open namespace change in #4071 touches javaSearch, but keeps the same parent walk root. This report concerns single-file search scope, independently of the JSON decoding in #4135.
Activity