Skip to content

fix(interface): add timeout to git clone during scan setup (#1105) - #1145

Open
jiffyaneesh wants to merge 3 commits into
usestrix:mainfrom
jiffyaneesh:fix/issue-1105-git-clone-timeout
Open

fix(interface): add timeout to git clone during scan setup (#1105)#1145
jiffyaneesh wants to merge 3 commits into
usestrix:mainfrom
jiffyaneesh:fix/issue-1105-git-clone-timeout

Conversation

@jiffyaneesh

@jiffyaneesh jiffyaneesh commented Aug 22, 2026

Copy link
Copy Markdown

Summary

Fixes #1105.

Adds a configurable timeout (defaulting to 300 seconds, with support for disabling via 0) to git clone executions in clone_repository during scan setup, configurable via CLI flag (--git-clone-timeout), settings / environment variable (STRIX_GIT_CLONE_TIMEOUT), or programmatically, while handling subprocess.TimeoutExpired gracefully with proper cleanup and descriptive error reporting.


Problem

When scanning a remote Git repository, prepare_run() invokes clone_repository() on the main thread before launching the sandbox environment. Previously, clone_repository() called subprocess.run([git_executable, "clone", repo_url, str(clone_path)], ...) without a timeout= 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

  1. Configurable Settings & Environment Variable:
    • Added git_clone_timeout: int = Field(default=300, ge=0, alias="STRIX_GIT_CLONE_TIMEOUT") to RuntimeSettings in strix/config/settings.py.
    • Default is set to 300s (5 minutes) to safely accommodate larger repositories, with 0 disabling the timeout entirely.
  2. CLI Option:
    • Added --git-clone-timeout to strix/interface/cli_args.py so users can customize or disable (0) the clone timeout on a per-scan basis.
  3. clone_repository Updates:
    • Updated clone_repository() in strix/interface/utils.py to dynamically resolve effective timeout from explicit arguments, settings (load_settings().runtime.git_clone_timeout), or DEFAULT_GIT_CLONE_TIMEOUT_SECONDS = 300.0.
    • Supports disabling the timeout when timeout=0 (or git_clone_timeout=0) is passed.
    • Handled subprocess.TimeoutExpired: automatically cleans up any partially created temporary directory and raises a descriptive ValueError explaining how to increase or disable the limit (--git-clone-timeout / STRIX_GIT_CLONE_TIMEOUT).
  4. prepare_run Integration:
    • prepare_run() in strix/interface/scan_setup.py now passes args.git_clone_timeout to clone_repository().
  5. Unit Tests:
    • Added tests/test_clone_repository.py covering:
      • 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 when 0 is configured.
      • test_clone_repository_custom_timeout: Explicit timeout parameter propagation.
      • test_clone_repository_timeout_expired: TimeoutExpired cleanup and clear error messaging.
      • test_clone_repository_called_process_error: Propagating stderr from failed git executions.
      • test_clone_repository_git_not_found: FileNotFoundError handling when git is not available in PATH.
      • test_prepare_run_passes_git_clone_timeout: prepare_run propagating parsed CLI flag to clone operation.
  6. Code Quality:
    • Added # noqa: PLC0415 for deferred litellm import in strix/report/pricing.py.

Testing & Verification

  • Targeted Unit Tests:
    uv run pytest tests/test_clone_repository.py -v
    # 8 passed in 0.62s
  • Full Test Suite:
    uv run pytest
    # 934 passed, 2 warnings in 205s
  • Type Checking:
    uv run mypy strix/ tests/test_clone_repository.py
    # Success: no issues found in 97 source files
  • Linting & Formatting:
    uv run ruff check .
    uv run ruff format . --check
    # All checks clean

Environment & System Specs

  • OS: Linux x86_64 (Linux 7.0.0-29-generic)
  • Python: 3.12.14 (managed via uv)
  • uv: 0.12.5
  • Git: 2.53.0

@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR bounds repository cloning during scan setup and translates clone timeouts into a descriptive error after removing partial data.

  • Adds a 120-second default timeout and optional function parameter to clone_repository.
  • Adds focused tests for success, custom timeouts, timeout cleanup, Git failures, and missing Git.
  • Suppresses the deferred-import lint warning in LiteLLM pricing resolution.

Confidence Score: 4/5

The 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

Filename Overview
strix/interface/utils.py Adds timeout handling and cleanup to repository cloning, but the production setup path cannot override the fixed 120-second limit.
tests/test_clone_repository.py Adds focused unit coverage for timeout propagation and clone error handling.
strix/report/pricing.py Adds a targeted lint suppression to the existing deferred LiteLLM import without changing runtime behavior.
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

Comment thread strix/interface/utils.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

git clone during scan setup has no timeout

1 participant