fix(interface): add timeout to git clone during scan setup (#1105) - #1145
Open
jiffyaneesh wants to merge 3 commits into
Open
fix(interface): add timeout to git clone during scan setup (#1105)#1145jiffyaneesh wants to merge 3 commits into
jiffyaneesh wants to merge 3 commits into
Conversation
Contributor
Greptile SummaryThe PR bounds repository cloning during scan setup and translates clone timeouts into a descriptive error after removing partial data.
Confidence Score: 4/5The fixed production timeout should be made user-configurable before merging because valid slow clones otherwise abort scan preparation with no way to raise the limit. Every production clone uses the new 120-second default, so a healthy large or slow repository is forcibly terminated once that wall-clock limit expires even though the function advertises an override. Files Needing Attention: strix/interface/utils.py and strix/interface/scan_setup.py Important Files Changed
Prompt To Fix All With AI### Issue 1
strix/interface/utils.py:1562
**Fixed timeout aborts valid clones**
When a healthy repository needs more than 120 seconds to clone, production scan setup always applies this default because its sole caller supplies no timeout and no CLI or settings option exposes one, causing preparation to terminate the clone and abort the scan despite the parameter being described as configurable.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(interface): add timeout to git clone..." | Re-trigger Greptile |
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.
Summary
Fixes #1105.
Adds a configurable timeout (defaulting to 300 seconds, with support for disabling via
0) togit cloneexecutions inclone_repositoryduring scan setup, configurable via CLI flag (--git-clone-timeout), settings / environment variable (STRIX_GIT_CLONE_TIMEOUT), or programmatically, while handlingsubprocess.TimeoutExpiredgracefully with proper cleanup and descriptive error reporting.Problem
When scanning a remote Git repository,
prepare_run()invokesclone_repository()on the main thread before launching the sandbox environment. Previously,clone_repository()calledsubprocess.run([git_executable, "clone", repo_url, str(clone_path)], ...)without atimeout=parameter.If a remote Git server is unresponsive, hangs on authentication, or experiences dropped TCP connections, the Strix CLI would hang indefinitely without any error feedback or recovery mechanism.
Solution & Changes
git_clone_timeout: int = Field(default=300, ge=0, alias="STRIX_GIT_CLONE_TIMEOUT")toRuntimeSettingsinstrix/config/settings.py.0disabling the timeout entirely.--git-clone-timeouttostrix/interface/cli_args.pyso users can customize or disable (0) the clone timeout on a per-scan basis.clone_repositoryUpdates:clone_repository()instrix/interface/utils.pyto dynamically resolve effective timeout from explicit arguments, settings (load_settings().runtime.git_clone_timeout), orDEFAULT_GIT_CLONE_TIMEOUT_SECONDS = 300.0.timeout=0(orgit_clone_timeout=0) is passed.subprocess.TimeoutExpired: automatically cleans up any partially created temporary directory and raises a descriptiveValueErrorexplaining how to increase or disable the limit (--git-clone-timeout/STRIX_GIT_CLONE_TIMEOUT).prepare_runIntegration:prepare_run()instrix/interface/scan_setup.pynow passesargs.git_clone_timeouttoclone_repository().tests/test_clone_repository.pycovering:test_clone_repository_default_settings_timeout: Default settings timeout resolution.test_clone_repository_env_var_timeout: Resolving custom timeout from settings/environment.test_clone_repository_disabled_timeout: Disabling timeout when0is configured.test_clone_repository_custom_timeout: Explicit timeout parameter propagation.test_clone_repository_timeout_expired:TimeoutExpiredcleanup and clear error messaging.test_clone_repository_called_process_error: Propagating stderr from failed git executions.test_clone_repository_git_not_found:FileNotFoundErrorhandling when git is not available in PATH.test_prepare_run_passes_git_clone_timeout:prepare_runpropagating parsed CLI flag to clone operation.# noqa: PLC0415for deferredlitellmimport instrix/report/pricing.py.Testing & Verification
uv run pytest tests/test_clone_repository.py -v # 8 passed in 0.62suv run pytest # 934 passed, 2 warnings in 205suv run mypy strix/ tests/test_clone_repository.py # Success: no issues found in 97 source filesEnvironment & System Specs
Linux 7.0.0-29-generic)uv)