Skip to content

fix(git-sync): raise default git timeout to 300s and make it configurable per org - #755

Merged
neubig merged 2 commits into
mainfrom
fix/git-sync-timeout-492
Nov 14, 2026
Merged

neubig merged 2 commits into
mainfrom
fix/git-sync-timeout-492

Conversation

@neubig

@neubig neubig commented Nov 13, 2026

Copy link
Copy Markdown
Member

Why

Fixes #492. Git Sync's per-command timeout defaulted to 60 s. The first clone of a normal-sized repo over a slow link takes longer, so the first sync of an otherwise correct config failed with git command timed out after 60.0s. The only way to change it was AUTOMATION_GIT_SYNC_GIT_TIMEOUT_SECONDS and a restart, and the error did not say so.

Summary

  • GitSyncSettings.git_sync_git_timeout_seconds defaults to 300 s.
  • The timeout is now a per-org runtime setting, like interval_seconds:
    • PUT /v1/git-sync/config accepts git_timeout_seconds (10–3600 s; null reverts to the env default). It maps to the existing GitSyncSettings field, so the cycle, the lease TTL (max(300 s, 5 × timeout)) and /check all read it through the normal merge.
    • GET /v1/git-sync/status (and the PUT response) report the effective git_timeout_seconds.
  • The timeout error now names the setting to raise (git_timeout_seconds in the Git Sync config, or the env var), since that message is what the Git Sync error banner shows.

Scope: this does not change how git is spawned. The SSH hang in #491 is tracked separately in #493.

How to Test

uv run python -m pytest tests/test_git_sync_router.py tests/test_git_sync_client.py tests/test_git_sync.py tests/test_git_sync_backoff.py -n 4

209 passed. New tests: default is 300, env var sets the default, PUT sets/clears the override and the cycle's merged settings see it, out-of-range values are rejected with 422, and a timed-out git command's error names the setting. pre-commit passes on the changed files.

Live check: I ran the service from each checkout in local mode (SQLite, local agent-server). Git Sync pointed at a ~9 MB repo served by a local sshd, with the SSH link throttled to ~50 KB/s. A plain git clone of it takes ~100 s. Script: .pr/repro492.sh.

Before (main 949c001) After (this PR, 8e03c64)
before after

Notes

  • The Agent Canvas Git Sync form (OpenHands/OpenHands) can now show and edit this value from the same status/config API it already uses. Adding the input there is a frontend follow-up.
  • .pr/ holds temporary review evidence only; the release PR removes it.

This PR was created by an AI agent (OpenHands) on behalf of Graham Neubig.

…able per org

Fixes #492

Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions

Copy link
Copy Markdown
Contributor

📁 PR Artifacts Notice

This PR adds or changes temporary PR-specific documents under .pr/. They stay on this branch for review. After this PR merges, the next release PR removes them from main.

@neubig
neubig requested a review from all-hands-bot November 13, 2026 23:43
@github-actions github-actions Bot added the type: fix A bug fix label Nov 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Warning

Your comment is too long (maximum is 65536 characters), so the coverage report was not added. See the job log for how to reduce it.

@neubig
neubig requested review from all-hands-bot and removed request for all-hands-bot November 14, 2026 01:04
@neubig

neubig commented Nov 14, 2026

Copy link
Copy Markdown
Member Author

@all-hands-bot Please review the latest head 071aa4d. All CI checks pass and the branch merges cleanly with main.

This comment was created by an AI agent (OpenHands) on behalf of Graham Neubig.

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was posted by an AI agent (OpenHands).

Reviewed at head 071aa4da5e10b7465bcfa3488d5e5b5618340502 against issue #492 and the repository's review guidance.

Scope: git_sync/ is owned by this repository; the Canvas frontend follow-up is correctly left to OpenHands/OpenHands. The .pr/ evidence files follow the repo's PR-Specific Documents convention.

Correctness (verified in the workspace and against the current head):

  • The default change (60→300 s) and env-var override work as described; git_sync_git_timeout_seconds flows through resolve_effective_git_sync_settings to both PUT /config's response/GET /status and the sync cycle, and _lease_ttl (max(300, 5 × timeout)) reads the same merged settings, so the lease grows with the org's timeout.
  • The new override follows the repo's PATCH semantics: omitted fields stay unchanged (model_dump(exclude_unset=True)), an explicit null pops the override and reverts to the env default, and out-of-range values (0, -5, 5, 9.9, 3601) are rejected with 422 while 10–3600 are accepted. I exercised the schema, merge, and lease-TTL code paths directly.
  • POST /check clamps to its fixed 20 s operator-facing timeout (min(timeout, _CHECK_TIMEOUT_SECONDS)), so a raised org timeout does not slow the check form.
  • The timeout error message names both the per-org setting and the env var, which is what the error banner surfaces.
  • API contract change is additive: the new response field and optional request field are backward-compatible with the current Canvas consumer.

Tests: test_git_sync_client.py::TestTimeout, test_git_sync.py, and test_git_sync_backoff.py pass locally (99 passed); the router suite requires the PostgreSQL container fixture and is covered by the green unit-tests run on this exact head. All 10 CI checks pass at 071aa4d.

No material correctness, security, or compatibility findings.

✅ APPROVED

@neubig
neubig merged commit a3dcb6d into main Nov 14, 2026
10 checks passed
@openhands-release-bot openhands-release-bot Bot added the released: 1.33.0 Shipped in 1.33.0 label Nov 17, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in 1.33.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released: 1.33.0 Shipped in 1.33.0 type: fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

git_sync: default git_sync_git_timeout_seconds (60s) is too low for real-world repos

3 participants