fix(cli): short-circuit workspace-list when --workspace is set#112
fix(cli): short-circuit workspace-list when --workspace is set#112khaliqgant wants to merge 2 commits into
Conversation
…er 403 hint When agentworkforce login is invoked with --workspace, listWorkspacesForLogin should not be called — but the previous flow always listed first and only short-circuited the picker. That meant users hitting 403 on /api/v1/workspaces could not log in at all, even with the workspace id in hand. This PR: - Short-circuits listWorkspacesForLogin when opts.workspace is provided - Surfaces a clearer error when the list 403s, pointing at --workspace - Surfaces a clearer error when the list is empty (no workspaces yet) - Adds tests covering all three paths Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR adds workspace selection optimization to the login flow. When ChangesWorkspace Selection Optimization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
agentworkforce login --workspace <id>was failing withworkspace list failed: 403 ForbiddenbecauselistWorkspacesForLoginran unconditionally before--workspacewas checked. This PR makes--workspaceactually skip the list, which was the original intent.Repro (pre-fix)
The 403 itself is a separate concern — the user's access token from PKCE lacks the scope
GET /api/v1/workspacesrequires. That needs a relay-side scope fix (@agent-relay/cloud'sensureAuthenticatedrequestingworkspaces:read) OR a cloud-side route relaxation (return empty list for auth'd-but-no-workspaces users). This PR is the CLI-side mitigation so users with a known workspace id can still log in today.Changes
runLoginshort-circuitslistWorkspacesForLoginwhen--workspaceis setVerification
corepack pnpm -F @agentworkforce/cli typecheck— cleancorepack pnpm -F @agentworkforce/cli test— 192 pass / 0 fail (was 189 on main)Test plan
runLogin with --workspace skips the workspace list call and uses the provided workspacerunLogin without --workspace surfaces a --workspace hint when the workspaces list returns 403runLogin without --workspace surfaces a no-workspaces message when the list comes back empty🤖 Generated with Claude Code