Repository navigation
Conversation
Signed-off-by: Emre K <110906681+kocaemre@users.noreply.github.com>
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Review: PR #587 — fix: make Git Sync canonical gzip output deterministic
Scope: In-scope. openhands/automation/git_sync/serializer.py is this repository's single canonical tarball builder — canonical_tarball_bytes and deserialize_automation both call rebuild_tarball, and _stored_tarball_matches in loop.py compares those outputs byte-for-byte. The fix belongs exactly here; there is no cross-repository ownership question.
Change assessment: rebuild_tarball now wraps tarfile.open(mode="w") in gzip.GzipFile(mtime=0, filename="") instead of tarfile.open(mode="w:gz"), which took the gzip header MTIME from the wall clock. Tar member order, per-member mtime and modes are unchanged, so the change is confined to the gzip framing. Closing order (tar then gzip) is correct, and filename="" is not None, so no filename is derived from the fileobj.
Verified on head 0d093ca:
- Pre-fix reproduction against the old
w:gzimplementation: tworebuild_tarballcalls one second apart differ only in gzip MTIME (1000 vs 1001). - Post-fix: identical inputs at simulated
time.time()1000 and 1001 yield byte-identical output; the gzip MTIME field is 0 and the FLG byte is 0 (no embedded filename). canonical_tarball_bytes(rebuild_tarball(...)) == rebuild_tarball(...)— canonicalization is idempotent.tar xzfextracts the new stream with correct contents and the0755executable bit preserved, so the sandbox extraction path is unaffected.uv run --frozen python -m pytest tests/test_git_sync.py tests/test_git_sync_serializer.py -q -o addopts=''→ 97 passed, 2 pre-existing warnings, matching the author's claim;TestTarballUploadLifecyclepasses.- Ruff check/format and pyright on both changed files pass.
Acceptance criteria in #586 (labels bug, ready-for-dev, priority:low): deterministic canonical bytes across wall-clock seconds, a sleep-free regression test, canonical idempotence, and preserved reuse-vs-replace behavior — all covered by the new test plus the existing tarball-upload lifecycle tests.
Non-blocking note: the fork PR's Run tests, ci, and Docker workflows are action_required (awaiting maintainer approval to run on the fork head), so no full-suite CI result exists for this SHA. Focused tests pass locally; approving those runs is a maintainer action, not a code defect.
No material correctness, security, or compatibility findings.
✅ APPROVED
Summary
mtime=0, empty filename), so identical files and executable modes compare byte-for-byte across wall-clock seconds.Fixes #586.
Verification
uv run --frozen python -m pytest tests/test_git_sync_serializer.py::TestRebuildTarball::test_rebuild_is_identical_across_wall_clock_seconds -q -o addopts='' --tb=short→ 1 expected failure (gzip header differs at byte 4).uv run --frozen python -m pytest tests/test_git_sync.py tests/test_git_sync_serializer.py -q -o addopts='' --tb=short→ 97 passed (2 pre-existing deprecation warnings).uv run --frozen pre-commit run --files openhands/automation/git_sync/serializer.py tests/test_git_sync_serializer.py --show-diff-on-failure→ Ruff format/lint, pycodestyle, Pyright passed; YAML hook skipped (no YAML changed).git diff --check→ passed. Fulluv run --frozen python -m pytest tests/ -q -o addopts='' --tb=short --maxfail=1attempted but timed out at the local tool's 420-second limit; not claimed green.AI assistance was used for the patch and regression test; the author verified the behavior and checks above.
Jev-Fast-Audit
⚡ Jev fast audit · estimates · 0.30s · commit 0d093ca
Strongest signal: No primary concern selected.
Evidence: No primary concern to locate.
Coverage: complete supplied coverage; 4/4 hunks, 2/2 files.
All estimates and evidence