Skip to content

fix(create/link): fall back to default workspace when the token can't list workspaces#572

Open
netanelgilad wants to merge 1 commit into
mainfrom
claude/cli-workspaces-support-h5x81l
Open

fix(create/link): fall back to default workspace when the token can't list workspaces#572
netanelgilad wants to merge 1 commit into
mainfrom
claude/cli-workspaces-support-h5x81l

Conversation

@netanelgilad

@netanelgilad netanelgilad commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Note

Description

The workspace picker used by base44 create and base44 link calls the account-level GET /api/workspace/workspaces endpoint. 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • Added isWorkspaceListForbidden() to detect the workspace-scoped credential case (an ApiError with statusCode === 403).
  • Changed fetchWorkspaces() to catch that 403, update the task spinner to "Using your default workspace", and return null instead of throwing; all other errors still propagate.
  • Updated resolveWorkspaceId() to handle the null result by warning the user and falling back to the default workspace (returning undefined), while pointing them at --workspace <id> to target a specific one.
  • --workspace <id> and non-interactive behavior are unchanged.

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (npm test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated docs/ (AGENTS.md) if I made architectural changes

Additional Notes

New unit tests in packages/cli/tests/cli/workspace-select.spec.ts cover: explicit --workspace pass-through, non-interactive mode, the 403 fallback (with the --workspace hint 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

… 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
@netanelgilad netanelgilad self-assigned this Jul 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.1.5-pr.572.2976402

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.1.5-pr.572.2976402"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.1.5-pr.572.2976402"
  }
}

Preview published to npm registry — try new features instantly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants