Repository navigation
fix(sdk): list a git type change as an updated file - #6591
Conversation
git diff --name-status reports a type change (e.g. a file replaced by a symlink) as "T", which the parser did not know, so get_changes_in_repo raised GitCommandError and the whole change listing failed. Map "T" to UPDATED.
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Scope: The change lives in openhands-sdk/openhands/sdk/git/git_changes.py — squarely within this repository's ownership (Python SDK). The linked tracker item in #6348 ("a type change ('T', e.g. file -> symlink) is an unknown status and aborts the whole change listing") is labeled ready-for-dev and cross-referenced to this PR. Scope gate passes.
Correctness: git diff --name-status -z emits T with a single path (the parser's path_count logic correctly treats T as one-path, unlike R/C), and mapping it to GitChangeStatus.UPDATED is consistent with how M is treated — the path still exists and its content changed. The status enum values themselves are unchanged, so there is no REST/serialized-contract impact (the OpenAPI schema check on this head passes), and the change only widens accepted input. Since git_commits.py shares _parse_name_status, commit change listings handle T too.
Test evidence:
- The new regression test fails on
mainwithGitCommandError: Unexpected git status: T(reproduced via a worktree atorigin/mainwith the head's test file) and passes on this head, satisfying the repository's rule that a bug-fix regression test fails without the fix. uv run pytest tests/sdk/gitpasses on this head: 144 passed.ruff checkandruff format --checkare clean on both changed files.- All GitHub Actions checks on
b000470d8483be10c3236c4d289bf42b0d1f2ed5are successful.
Acceptance: The PR ports the issue's pinned test without its xfail marker, asserts the resulting status, and says "Part of #6348" as the tracker requires. No dependency changes, so the release-age policy does not apply.
No material correctness, security, compatibility, or acceptance-criterion findings.
✅ APPROVED
HUMAN:
just fixing a bug
AGENT:
Why
The change parser accepts
M,A,D,U(plusR/C) fromgit diff --name-statusand raisesGitCommandError("Unexpected git status: T")for anything else. Git usesTfor a type change, such as a regular file replaced by a symlink. One such file in the working tree makesget_changes_in_reporaise, so the agent server's/api/git/changesreturns a 400 and none of the other changes are listed.Summary
TtoGitChangeStatus.UPDATEDand accept it next to the other single-letter statuses. The path still exists and its content changed, which is what UPDATED means for the other statuses.xfailmarker. It also checks the status, and inlines the two commit commands instead of adding a helper.Issue Number
Part of #6348 (item: "a type change ('T', e.g. file -> symlink) is an unknown status and aborts the whole change listing").
How to Test
test_get_changes_in_repo_type_change_does_not_abort_listingfails onmain(GitCommandError: Unexpected git status: T) and passes here, listing bothlink.txtandother.txtas updated;tests/sdk/gitpasses (144).Type
🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdkpython-node-runtimepython-node-runtimepython-node-runtimegolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:b000470-pythonRun
All tags pushed for this build
About Multi-Architecture Support
b000470-python) is a multi-arch manifest supporting both amd64 and arm64b000470-python-amd64) are also available if needed