{"record":{"id":"73e5beb8fec06e4d","repo":"multica-ai/multica","slug":"list-workspaces-w-73e5be","errorCode":null,"errorMessage":"list workspaces: %w","messagePattern":"list workspaces: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_workspace.go","lineNumber":235,"sourceCode":"\tID   string `json:\"id\"`\n\tName string `json:\"name\"`\n\tSlug string `json:\"slug\"`\n}\n\n// fetchWorkspaces lists all workspaces the authenticated user belongs to. It\n// is shared by `list` and `switch` so both see the same access-controlled view\n// of workspaces.\nfunc fetchWorkspaces(ctx context.Context, cmd *cobra.Command) ([]workspaceSummary, error) {\n\tserverURL := resolveServerURL(cmd)\n\ttoken := resolveToken(cmd)\n\tif token == \"\" {\n\t\treturn nil, fmt.Errorf(\"not authenticated: run 'multica login' first%s\", daemonPortOnlyContextHint())\n\t}\n\n\tclient := cli.NewAPIClient(serverURL, \"\", token)\n\tvar workspaces []workspaceSummary\n\tif err := client.GetJSON(ctx, \"/api/workspaces\", &workspaces); err != nil {\n\t\treturn nil, fmt.Errorf(\"list workspaces: %w\", err)\n\t}\n\treturn workspaces, nil\n}\n\nfunc runWorkspaceList(cmd *cobra.Command, _ []string) error {\n\tctx, cancel := cli.APIContext(context.Background())\n\tdefer cancel()\n\n\tworkspaces, err := fetchWorkspaces(ctx, cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\toutput, _ := cmd.Flags().GetString(\"output\")\n\tif output == \"json\" {\n\t\treturn cli.PrintJSON(os.Stdout, workspaces)\n\t}\n","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_workspace.go#L217-L253","documentation":"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.","triggerScenarios":"`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).","commonSituations":"Daemon stopped or restarting, server URL env pointing at a stale port, token expired between the empty-check and the request, server-side outage.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"multica status >/dev/null 2>&1 || { echo 'server down or URL wrong'; exit 1; }","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["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."],"tags":["cli","api","auth","network","workspace"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}