multica-ai/multica · error
list workspaces: %w
Error message
list workspaces: %w
What it means
The GET /api/workspaces call inside fetchWorkspaces failed, wrapping the API client error. This is the network/HTTP stage of workspace listing — unlike the 'not authenticated' sibling error, a token was present but the request itself did not succeed.
Source
Thrown at server/cmd/multica/cmd_workspace.go:235
ID string `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
}
// fetchWorkspaces lists all workspaces the authenticated user belongs to. It
// is shared by `list` and `switch` so both see the same access-controlled view
// of workspaces.
func fetchWorkspaces(ctx context.Context, cmd *cobra.Command) ([]workspaceSummary, error) {
serverURL := resolveServerURL(cmd)
token := resolveToken(cmd)
if token == "" {
return nil, fmt.Errorf("not authenticated: run 'multica login' first%s", daemonPortOnlyContextHint())
}
client := cli.NewAPIClient(serverURL, "", token)
var workspaces []workspaceSummary
if err := client.GetJSON(ctx, "/api/workspaces", &workspaces); err != nil {
return nil, fmt.Errorf("list workspaces: %w", err)
}
return workspaces, nil
}
func runWorkspaceList(cmd *cobra.Command, _ []string) error {
ctx, cancel := cli.APIContext(context.Background())
defer cancel()
workspaces, err := fetchWorkspaces(ctx, cmd)
if err != nil {
return err
}
output, _ := cmd.Flags().GetString("output")
if output == "json" {
return cli.PrintJSON(os.Stdout, workspaces)
}
View on GitHub (pinned to 2c0912b6ec)
Solutions
- Check the wrapped error: connection refused → start/restart the server or fix the server URL; 401 → `multica login`.
- Verify the base URL with `multica status` or a direct curl of /api/workspaces.
- Retry on 5xx once the server is healthy.
Defensive patterns
Strategy: try-catch
Validate before calling
multica status >/dev/null 2>&1 || { echo 'server down or URL wrong'; exit 1; } Try / catch
out=$(multica workspace list 2>&1) || { case "$out" in *401*|*unauthorized*) multica login; multica workspace list ;; *refused*|*unreachable*) echo 'server unreachable'; exit 1 ;; *) echo "$out"; exit 1 ;; esac; } Prevention
- Health-check the server before workspace operations in scripts.
- Pin the server URL explicitly (--server or env) instead of relying on discovery.
- Treat 5xx as transient: retry once after the daemon reports healthy.
When it happens
Trigger: `multica workspace list` / `switch` while the server is down or returns 401 (expired token) / 403 / 5xx, or the resolved server URL is wrong (connection refused, TLS failure).
Common situations: Daemon stopped or restarting, server URL env pointing at a stale port, token expired between the empty-check and the request, server-side outage.
Related errors
AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15).
Data as JSON: /api/errors/73e5beb8fec06e4d.
Report an issue: GitHub.