fix(create/link): fall back to default workspace when the token can't list workspaces#572
Open
netanelgilad wants to merge 1 commit into
Open
fix(create/link): fall back to default workspace when the token can't list workspaces#572netanelgilad wants to merge 1 commit into
netanelgilad wants to merge 1 commit into
Conversation
… list workspaces The interactive workspace picker calls the account-level GET /api/workspace/workspaces endpoint to decide whether to prompt. A CLI credential scoped to a single workspace (e.g. a workspace API key sent via BASE44_API_KEY, which the client prefers over the device-login token) can't call that endpoint and the server returns 403 — which previously aborted the whole create/link flow. Treat a 403 from the workspace list as 'can't enumerate workspaces': warn, and fall back to the default workspace (send no organization_id, exactly the pre-feature behavior) instead of failing. Non-403 errors still propagate. Passing --workspace <id> continues to bypass the list entirely. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0171Y6jogaAWB1suBYaEULp1
Contributor
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.1.5-pr.572.2976402Prefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.1.5-pr.572.2976402"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.1.5-pr.572.2976402"
}
}
Preview published to npm registry — try new features instantly! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Description
The workspace picker used by
base44 createandbase44 linkcalls the account-levelGET /api/workspace/workspacesendpoint. A credential scoped to a single workspace (a workspace API key, or a login completed inside a workspace) can't call that endpoint and gets a 403, which previously failed the whole command. This PR treats that 403 as "can't list" and gracefully falls back to the default workspace, since the picker is only a convenience.Related Issue
None
Type of Change
Changes Made
isWorkspaceListForbidden()to detect the workspace-scoped credential case (anApiErrorwithstatusCode === 403).fetchWorkspaces()to catch that 403, update the task spinner to "Using your default workspace", and returnnullinstead of throwing; all other errors still propagate.resolveWorkspaceId()to handle thenullresult by warning the user and falling back to the default workspace (returningundefined), while pointing them at--workspace <id>to target a specific one.--workspace <id>and non-interactive behavior are unchanged.Testing
npm test)Checklist
docs/(AGENTS.md) if I made architectural changesAdditional Notes
New unit tests in
packages/cli/tests/cli/workspace-select.spec.tscover: explicit--workspacepass-through, non-interactive mode, the 403 fallback (with the--workspacehint in the warning), rethrowing non-403 errors (e.g. 500), and the single personal-workspace case.🤖 Generated by Claude | 2026-07-22 13:50 UTC | 2976402