Skip to content

[OPIK-5754] [SDK] fix(runner): validate git repository before running SearchFiles#6163

Merged
petrotiurin merged 5 commits intomainfrom
petrotiurin/OPIK-5754-search-files-tests
Apr 10, 2026
Merged

[OPIK-5754] [SDK] fix(runner): validate git repository before running SearchFiles#6163
petrotiurin merged 5 commits intomainfrom
petrotiurin/OPIK-5754-search-files-tests

Conversation

@petrotiurin
Copy link
Copy Markdown
Contributor

@petrotiurin petrotiurin commented Apr 9, 2026

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.

  • Extracted check_git_repo() into common.py, reused by both SearchFilesHandler and ListFilesHandler instead of duplicating the validation logic
  • git_ls_files() now raises CommandError (codes: not_a_git_repository, git_not_available, search_failed) instead of returning None, making failures explicit
  • ListFilesHandler drops the os.walk fallback — it now requires a git repo and raises proper errors if one isn't present
  • SearchFilesHandler adds --untracked to git grep so untracked (non-ignored) files are also searched
  • snapshot.build_checklist() catches CommandError from git_ls_files() and falls back to os.walk for best-effort checklist generation (unchanged behavior)

Change checklist

  • User facing
  • Documentation update

Issues

  • OPIK-5754

AI-WATERMARK

AI-WATERMARK: yes

  • Tools: Claude Code
  • Model(s): claude-sonnet-4-6
  • Scope: full implementation
  • Human verification: code review + test run

Testing

cd sdks/python && python -m pytest tests/unit/runner/ -q
# 285 passed
  • Git repo validation: verified not_a_git_repository and git_not_available error codes raised correctly
  • Untracked file search: added test_search_files__untracked_file__is_searched — creates a file after the initial commit and confirms git grep --untracked finds it
  • build_checklist fallback: existing snapshot tests confirm os.walk path still works when git is unavailable

Documentation

N/A

… 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>
@github-actions github-actions bot added python Pull requests that update Python code tests Including test files, or tests related like configuration. Python SDK labels Apr 9, 2026
@petrotiurin petrotiurin marked this pull request as ready for review April 9, 2026 15:35
@petrotiurin petrotiurin requested a review from a team as a code owner April 9, 2026 15:35
collincunn
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>
petrotiurin and others added 2 commits April 9, 2026 18:07
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@petrotiurin petrotiurin merged commit cb4bb4c into main Apr 10, 2026
127 of 130 checks passed
@petrotiurin petrotiurin deleted the petrotiurin/OPIK-5754-search-files-tests branch April 10, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Python SDK python Pull requests that update Python code tests Including test files, or tests related like configuration.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants