fix: use query parameters for git API endpoints to preserve path slashes#2249
fix: use query parameters for git API endpoints to preserve path slashes#2249chuckbutkus merged 5 commits intomainfrom
Conversation
API breakage checks (Griffe)Result: Failed Log excerpt (first 1000 characters) |
Agent server REST API breakage checks (OpenAPI)Result: Passed |
Add support for both query parameters (preferred) and path parameters (legacy/backwards compatible) for git/changes and git/diff endpoints. Query parameter method (?path=/workspace/project) is preferred as it avoids URL path normalization issues with Traefik/Gateway API where encoded slashes (%2F) in path segments would be decoded and normalized, causing leading slashes to be lost. Path parameter method (/changes/workspace/project) is maintained for backwards compatibility with existing clients. Co-authored-by: openhands <openhands@all-hands.dev>
1709bef to
663f4b5
Compare
all-hands-bot
left a comment
There was a problem hiding this comment.
Taste Rating: 🟢 Good taste
Clean, pragmatic solution to a real Traefik path normalization issue. The refactoring into helper functions is solid, backward compatibility is maintained, and test coverage is comprehensive.
Eval Risk Flag 🚩
While the implementation is sound, this PR touches git tool endpoints that agents use during coding tasks. Per review policy, flagging for lightweight eval verification before merge, even though:
- Changes are fully backward compatible (old path-based endpoints unchanged)
- New query param endpoints are additive, fixing cases that were previously broken
- Risk profile is low since existing behavior is preserved
Technical Notes
The solution correctly addresses the core issue: query parameters avoid Traefiks URL path normalization, so absolute paths like /workspace/project no longer get mangled. The test coverage includes this critical use case.
Recommendation: Run lightweight evals to verify git operations still work correctly, then merge. Code quality is not a concern.
…hes (OpenHands#2249) Cherry-pick from upstream 97ab053
Summary
Change git/changes and git/diff endpoints from path parameters to query parameters to fix URL path normalization issues with Traefik/Gateway API.
When paths like /workspace/project were URL-encoded in path segments (%2Fworkspace%2Fproject), Traefik would decode them and normalize the resulting double slashes, causing the leading slash to be lost.
Using query parameters avoids this issue as they are passed through without path normalization.
Checklist
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22golang: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:9dda7a0-pythonRun
All tags pushed for this build
About Multi-Architecture Support
9dda7a0-python) is a multi-arch manifest supporting both amd64 and arm649dda7a0-python-amd64) are also available if needed