Repository navigation
fix(tools): run ripgrep from the search path so directory globs match - #7053
Open
JefferyLiu6 wants to merge 4 commits into
Open
JefferyLiu6 wants to merge 4 commits into
JefferyLiu6 wants to merge 4 commits into
Conversation
1 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HUMAN:
GlobExecutor._execute_with_ripgrep()now runsrgwithcwd=search_path. Previously, ripgrep evaluated-gpatterns containing/(likesrc/**/*.ts) against the process working directory rather than the target path, returning nothing whenever they differed.Added a parametrized regression test in
tests/tools/globcoveringsrc/*.ts,src/**/*.ts, literal paths, custompathargs, and verifying the caller'scwdstays untouched. Leaving the Python fallback's**/prefix discrepancy for a separate issue.AGENT:
Why
With the ripgrep backend,
GlobToolreturns "No files found" for any relative pattern that contains/(src/*.ts,src/**/*.ts,src/app.ts) whenever the process working directory is not the search path. ripgrep resolves a-gglob that contains/against its own working directory, and_execute_with_ripgrep()never set one.src/**/*.tsis the example in the tool description.Summary
cwd=search_pathinGlobExecutor._execute_with_ripgrep(). The command and the output parsing are unchanged.src/*.ts,src/**/*.ts, a literalsrc/app.ts, and thepathargument. It also asserts the process working directory is unchanged.Issue Number
Fixes #7052
How to Test
With ripgrep on
PATH:67 passed. Reverting onlyopenhands-tools/openhands/tools/glob/impl.pywhile keeping the new test gives4 failed, 63 passed, each failure beingassert set() == {'src/app.ts', ...}. Without ripgrep the four new cases skip.Verified on macOS (Apple Silicon) with ripgrep 15.2.0 and Python 3.13.5, and on Linux with ripgrep 14.1.0.
The underlying ripgrep behavior, without the SDK:
Video/Screenshots
N/A. Before and after, from the reproducer in #7052:
Design Doc
N/A.
Type
Notes
/and patterns starting with**/behave as before; the existing glob tests pass unchanged.search_pathis already resolved before the call, so the path argument andcwdagree even when the search path is reached through a symlink (for example/varon macOS).**/to patterns without**, sopkg/*.pymatches at any depth there but only at the search root under ripgrep. That needs a decision on the intended behavior and is better as a separate issue.chdir), fix(tools): match path includes against relative paths #6680 (grepinclude) or feat(tools): opt-in workspace containment for file tools #5971 (workspace containment).