fix: add workspace routing to cloud upload and API client#704
fix: add workspace routing to cloud upload and API client#704
Conversation
Cloud upload, project existence checks, and project creation now resolve and pass the X-Workspace-ID header for teams workspace support. The get_client() per-project routing also auto-resolves workspace from project config when not explicitly provided. Fixes #703 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Drew Cain <groksrc@gmail.com>
|
Claude finished @groksrc's task in 1m 58s —— View job PR Review: fix/cloud-upload-workspace-routing
OverviewThis PR correctly routes Issues Found🔴 Breaking test:
|
| Category | Status | Notes |
|---|---|---|
| Python 3.12+ type annotations | ✅ | Both str | None and Optional[str] used |
| Async patterns | ✅ | asynccontextmanager usage is correct |
| FastAPI/Typer conventions | ✅ | Typer CLI patterns followed |
| 100-char line length | ✅ | Within limits |
| No commented-out code | ✅ | |
| Unit tests for new code | ❌ | Missing workspace header assertions and auto-resolve tests |
| 100% test coverage | New branches in workspace resolution uncovered | |
| No hardcoded secrets | ✅ | |
| No sensitive data in logs | ✅ | workspace ID is logged, which seems acceptable |
| Input validation | ✅ | Truthy check on workspace is appropriate |
| Local-first architecture preserved | ✅ | Workspace only affects cloud routing |
| Windows path compatibility | ✅ | No path comparisons in changed code |
| No emoji/unicode in console output | ✅ |
Summary
The workspace routing logic itself is correct and well-structured. The critical blocker is that the existing test test_cloud_upload_uses_control_plane_client will fail because fake_project_exists doesn't accept the new workspace keyword argument. Additional tests for the new workspace header behavior are needed to maintain 100% coverage.
- Fix fake_project_exists and fake_get_client signatures in upload routing test - Add config_manager fixture to upload routing test - Add tests for get_cloud_control_plane_client with workspace header - Add tests for get_client auto-resolving workspace from project config and default_workspace - Add tests for explicit workspace overriding config - Add tests for _workspace_headers helper and cloud_utils workspace passing - Add missing docstring for workspace param in fetch_cloud_projects Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Drew Cain <groksrc@gmail.com>
|
Claude finished @groksrc's task in 2m 11s —— View job PR Review: fix/cloud-upload-workspace-routing
OverviewThis revision addresses all critical issues from the previous review. The workspace routing logic is sound, the broken test is fixed, and comprehensive workspace coverage has been added for the Fixed Since Last Review ✅
Remaining Issues🟡 Upload command workspace resolution branches not exercisedFile: entry = config.projects.get(project)
if entry and entry.workspace_id:
workspace = entry.workspace_id
elif config.default_workspace:
workspace = config.default_workspaceThe sole test in Two tests would cover this:
🟢 Minor:
|
| Category | Status | Notes |
|---|---|---|
| Python 3.12+ type annotations | Optional[str] in async_client.py — pre-existing |
|
| Async patterns | ✅ | asynccontextmanager usage is correct throughout |
| FastAPI/Typer conventions | ✅ | Followed correctly |
| 100-char line length | ✅ | Within limits |
| No commented-out code | ✅ | |
_workspace_headers unit tests |
✅ | Both with/without workspace |
| Cloud utils workspace header tests | ✅ | All three functions asserted |
get_client() workspace auto-resolve tests |
✅ | Project entry, default_workspace, and explicit override all covered |
get_cloud_control_plane_client workspace test |
✅ | Both with/without workspace |
| Upload command workspace resolution | ❌ | entry.workspace_id and default_workspace branches uncovered |
| No hardcoded secrets | ✅ | |
| No sensitive data in logs | ✅ | workspace ID in dim console output is acceptable |
| Input validation | ✅ | Truthy check on workspace is appropriate |
| Local-first architecture preserved | ✅ | Workspace only affects cloud routing |
| Windows path compatibility | ✅ | No path comparisons in changed code |
Summary
All critical issues from the previous review are resolved. The one remaining gap is test coverage for the upload command's workspace resolution logic — the entry.workspace_id and default_workspace branches in upload_command.py:80-84 aren't exercised by any test. Adding two focused tests there would satisfy the 100% coverage requirement and make this PR ready to merge.
Summary
get_cloud_control_plane_client()now accepts aworkspaceparam and sendsX-Workspace-IDheadercloud_utilsfunctions (fetch_cloud_projects,create_cloud_project,project_exists) now accept and pass workspaceuploadcommand resolves workspace from per-projectworkspace_idordefault_workspaceget_client()per-project routing auto-resolves workspace from project config entryTest plan
bm cloud upload ~/aitext --project aitext --dry-runshows correct workspacebm cloud upload ~/aitext --project aitext --create-projectcreates project in teams workspaceFixes #703
🤖 Generated with Claude Code