fix(docker): normalize bare repo name in git changes API path - #59
Conversation
There was a problem hiding this comment.
The fix correctly addresses the 500 error when the frontend sends bare GitHub repo names instead of . for the workspace root. The implementation extracts a shared normalizeGitUrl() function with proper fallback logic and includes comprehensive test coverage (10 test cases). The regex patterns correctly handle URL-encoded paths, non-encoded paths, and bare repo names in the right priority order. No defects found that block merge.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
π Security Scan ResultsStatus: π‘ HIGH ISSUES - Review required!Summary
NPM Vulnerabilities
Security Score: N/A/10Please run |
π Security Scan ResultsStatus: π‘ HIGH ISSUES - Review required!Summary
NPM Vulnerabilities
Security Score: N/A/10Please run |
π Security Scan ResultsStatus: π‘ HIGH ISSUES - Review required!Summary
NPM Vulnerabilities
Security Score: N/A/10Please run |
π Security Scan ResultsStatus: π‘ HIGH ISSUES - Review required!Summary
NPM Vulnerabilities
Security Score: N/A/10Please run |
π Security Scan ResultsStatus: π‘ HIGH ISSUES - Review required!Summary
NPM Vulnerabilities
Security Score: N/A/10Please run |
π Security Scan ResultsStatus: π‘ HIGH ISSUES - Review required!Summary
NPM Vulnerabilities
Security Score: N/A/10Please run |
π Security Scan ResultsStatus: π‘ HIGH ISSUES - Review required!Summary
NPM Vulnerabilities
Security Score: N/A/10Please run |
The frontend sends the GitHub repo name (e.g., "openhands-infra") in /api/git/changes/<repo-name>, but the agent-server expects "." for the workspace root since repos are cloned at /workspace/project. Extract shared normalizeGitUrl() function in patch-fix.js that handles: - Bare repo names β "." (the new fix) - URL-encoded /workspace/project paths β "." - Non-encoded //workspace/project paths β "." - Subdirectory paths β relative path Add regression test with 10 cases covering all path formats.
The previous snapshot was generated with a stale Docker build context. Regenerate to match the current patch-fix.js content hash.
TC-030: Verify Changes tab works for conversations without a GitHub repo connected (no-repo scenario). TC-031: Regression test for the bare repo name bug β verifies the Changes tab works when a GitHub repo is connected and the frontend sends the repo name instead of "." in /api/git/changes/ path. Also update select-e2e-tests.sh to include both TCs in RUNTIME_TESTS category (triggered by docker/ changes).
β¦tion The bare repo name bug only triggers when a conversation has a GitHub repo connected via the OpenHands integration. Manual git clone inside the sandbox does not set the repo in conversation metadata, so the frontend won't send the repo name in the git changes API path.
TC-031 no longer requires GitHub integration. Instead, it verifies the normalizeGitUrl() interceptor by calling fetch() with a bare repo name from the browser console of any running conversation. This was validated on staging β console logs confirm the rewrite works correctly. Also documents the alternative full-flow approach using POST /api/v1/app-conversations with selected_repository for public repos.
The previous fix only handled bare repo names sent directly by the frontend. The actual bug path is: frontend sends URL-encoded %2Fworkspace%2Fproject%2F<repo-name>, the workspace prefix stripping regex removes %2Fworkspace%2Fproject%2F leaving just <repo-name>, but the bare name catch-all was guarded by `if (url === before)` and skipped since the URL had already been modified. Fix: Remove the guard and restructure the regexes so that: 1. Workspace root + single trailing segment (repo name) -> "." 2. Workspace root + multi-segment sub-path -> preserved 3. Bare repo name (no workspace prefix) -> "." Add 3 new regression tests for the exact bug path observed in production (URL-encoded workspace path with repo directory name).
The diff API receives paths like %2Fworkspace%2Fproject%2Frepo%2Ffile which need the workspace+repo prefix stripped to leave just the file path. Previously only the changes API was handled (repo name -> "."). The normalizeGitUrl function now: 1. Strips workspace+repo prefix from URL-encoded paths, keeping file 2. Strips workspace+repo prefix from non-encoded paths, keeping file 3. For bare repo%2Ffile paths, extracts file after first %2F 4. For bare repo name only, rewrites to "." The bare-name catch-all is guarded by if(url===before) to avoid clobbering valid file paths produced by workspace stripping. Adds 19 regression tests covering changes and diff API patterns. Updates TC-031 E2E test case to cover diff API verification.
32421a4 to
a79b3fa
Compare
π Security Scan ResultsStatus: π‘ HIGH ISSUES - Review required!Summary
NPM Vulnerabilities
Security Score: N/A/10Please run |
## [1.2.0] - 2026-03-11 ### Added #### Sandboxes - **Startup timing instrumentation and SOCI support** (#58) - Added structured timing logs (`sandbox-startup-timing`) to benchmark sandbox startup phases in `/start` and `/resume` routes. - Integrated SOCI v2 index generation via `soci convert` for Fargate lazy image loading (requires `soci` CLI >= v0.10). - Introduced `sandboxSociImageUri` CDK context parameter for SOCI-enabled sandbox image override. - Exported sandbox image ECR URI as `CfnOutput` for SOCI index generation scripts. ### Changed #### Documentation - **Improved README for discoverability and engagement** (#60) - Restructured README to include a hero section, badges, and explicit value propositions. - Transformed features list into an emoji-tagged Key Features section for easier scanning. - Enhanced comparison tables and quick links for first-time visitor comprehension. ### Fixed #### Docker - **Correct VS Code port mapping from 60001 to 8001** (#62) - Resolved 502 runtime subdomain errors caused by incorrect port mapping (`60001` β `8001`) in `patch-exposed-urls.py`. - Fixed `can_connect(ip, 60001)` requests that failed to establish upstream connections due to mismatched port configurations in the agent-server SDK. - **Preserve project/<repo> path for nested repo git changes** (#61) - Corrected empty Changes tab for conversations linked to GitHub repositories. - Updated `normalizeGitUrl()` to preserve `project/<repo>` paths for accurate nested repo resolution. - Removed unnecessary intermediate `git init /workspace/project` repo creation shadowing actual repo changes. - **Normalize git API paths for connected repos** (#59) - Fixed 500 errors in git Changes tab when connecting GitHub repositories to conversations. - Adjusted `patch-fix.js` to properly normalize workspace paths containing nested repo directories. Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Summary
Fix git Changes tab 500 errors when a GitHub repo is connected to a conversation. Both the changes list API and the file diff API were broken because
patch-fix.jsdidn't properly normalize workspace paths containing the repo directory name.Root Cause
When a GitHub repo is connected via
selected_repository, the frontend sends absolute paths to the git API:%2Fworkspace%2Fproject%2Fopenhands-infra.(workspace root)%2Fworkspace%2Fproject%2Fopenhands-infra%2F.gitignore.gitignoreWithout normalization, the agent-server looks for wrong paths (
/workspace/openhands-infraor/workspace/openhands-infra/project/openhands-infra) and returns HTTP 500.Fix
The
normalizeGitUrl()function inpatch-fix.jsnow handles all path forms:%2Fworkspace%2Fproject%2F<repo>) β strips prefix, keeps file path or returns.//workspace/project/<repo>) β same treatmentopenhands-infra) β rewrites to.openhands-infra%2F.gitignore) β extracts file pathThe bare-name catch-all is guarded by
if (url === before)to avoid clobbering valid file paths already extracted by workspace stripping.Test plan
npm run build)npm run test) β 19 regression tests for all path patterns908266872b374b039fb60bdb4236f36d)%2Fworkspace%2Fproject%2Fopenhands-infraβ/api/git/changes/.β 200%2Fworkspace%2Fproject%2Fopenhands-infra%2F.gitignoreβ/api/git/diff/.gitignoreβ 200Checklist
docker/test_patch_fix_git_paths.js)test/E2E_TEST_CASES.md)test/select-e2e-tests.sh)