[OPIK-5754] [SDK] fix(runner): validate git repository before running SearchFiles#6163
Merged
petrotiurin merged 5 commits intomainfrom Apr 10, 2026
Merged
Conversation
… SearchFiles SearchFiles was silently failing when repo_root was not a git repository. Add upfront validation using git rev-parse and return a clear not_a_git_repository error instead of letting git grep fail obscurely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
collincunn
previously approved these changes
Apr 9, 2026
…list_files - Extract check_git_repo() into common.py, reused by both SearchFiles and ListFiles - git_ls_files() now raises CommandError instead of returning None - ListFilesHandler drops os.walk fallback; raises not_a_git_repository / git_not_available - snapshot.build_checklist() catches CommandError and falls back to os.walk for best-effort checklist Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sdks/python/tests/unit/runner/bridge_handlers/test_list_files.py
Outdated
Show resolved
Hide resolved
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
collincunn
requested changes
Apr 9, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
collincunn
approved these changes
Apr 9, 2026
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.
Details
Strengthens git integration in the runner's bridge handlers by making git a hard requirement for file operations, and extends search coverage to untracked files.
check_git_repo()intocommon.py, reused by bothSearchFilesHandlerandListFilesHandlerinstead of duplicating the validation logicgit_ls_files()now raisesCommandError(codes:not_a_git_repository,git_not_available,search_failed) instead of returningNone, making failures explicitListFilesHandlerdrops theos.walkfallback — it now requires a git repo and raises proper errors if one isn't presentSearchFilesHandleradds--untrackedtogit grepso untracked (non-ignored) files are also searchedsnapshot.build_checklist()catchesCommandErrorfromgit_ls_files()and falls back toos.walkfor best-effort checklist generation (unchanged behavior)Change checklist
Issues
AI-WATERMARK
AI-WATERMARK: yes
Testing
not_a_git_repositoryandgit_not_availableerror codes raised correctlytest_search_files__untracked_file__is_searched— creates a file after the initial commit and confirmsgit grep --untrackedfinds itbuild_checklistfallback: existing snapshot tests confirmos.walkpath still works when git is unavailableDocumentation
N/A