{"record":{"id":"03173d17e16faa75","repo":"multica-ai/multica","slug":"list-workspaces-w","errorCode":null,"errorMessage":"list workspaces: %w","messagePattern":"list workspaces: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_login.go","lineNumber":112,"sourceCode":"\t\treturn err\n\t}\n\tif cfg.Token == \"\" {\n\t\treturn fmt.Errorf(\"not authenticated\")\n\t}\n\tif cfg.ServerURL == \"\" {\n\t\treturn fmt.Errorf(\"server URL not configured\")\n\t}\n\n\tclient := cli.NewAPIClient(normalizeAPIBaseURL(cfg.ServerURL), \"\", cfg.Token)\n\tctx, cancel := cli.APIContext(context.Background())\n\tdefer cancel()\n\n\tvar workspaces []struct {\n\t\tID   string `json:\"id\"`\n\t\tName string `json:\"name\"`\n\t}\n\tif err := client.GetJSON(ctx, \"/api/workspaces\", &workspaces); err != nil {\n\t\treturn fmt.Errorf(\"list workspaces: %w\", err)\n\t}\n\n\tif len(workspaces) == 0 {\n\t\tvar err error\n\t\tworkspaces, err = waitForWorkspaceCreation(cmd, client)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif len(workspaces) == 0 {\n\t\t\tfmt.Fprintln(os.Stderr, \"\\nNo workspaces found.\")\n\t\t\treturn nil\n\t\t}\n\t}\n\n\t// Set default workspace if not set.\n\tif cfg.WorkspaceID == \"\" {\n\t\tcfg.WorkspaceID = workspaces[0].ID\n\t}","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_login.go#L94-L130","documentation":"Returned by the `multica login` flow when the initial GET /api/workspaces request fails. The CLI builds an API client from the stored config (cfg.ServerURL, cfg.Token) and wraps any transport/HTTP/decode failure from client.GetJSON with the 'list workspaces' prefix. The underlying %w chain carries the real cause: unreachable server, 401 from a bad/missing token, or a malformed response body.","triggerScenarios":"GET {ServerURL}/api/workspaces returning non-2xx (expired token -> 401), connection refused (server not running at the configured URL), TLS errors against a self-signed cert, or a response that is not a JSON array of {id,name} objects.","commonSituations":"Running `multica login` before `multica server` is up; MULTICA_SERVER_URL pointing at the wrong host/port; a token saved from a previous environment that the new server does not recognize; DNS or VPN issues for remote servers.","solutions":["Check that the server is running and reachable: curl the /api/workspaces endpoint printed in the error's ServerURL.","Verify the configured server URL (config file or MULTICA_SERVER_URL env) matches where the server actually listens.","Re-run login without a stale token so a fresh one is issued; inspect cfg.Token in the CLI config.","If the wrapped error mentions x509/TLS, import the server certificate or use a proper CA-signed cert."],"exampleFix":"// before\nMULTICA_SERVER_URL=http://localhost:9999 multica login\n// -> list workspaces: GET \"http://localhost:9999/api/workspaces\": connection refused\n\n// after\nmultica server &   # start server on its real port (e.g. 8080)\nMULTICA_SERVER_URL=http://localhost:8080 multica login","handlingStrategy":"try-catch","validationCode":"if cfg.ServerURL == \"\" { return fmt.Errorf(\"server URL not configured\") }\nif err := healthCheck(cfg.ServerURL); err != nil { return fmt.Errorf(\"server unreachable: %w\", err) }","typeGuard":null,"tryCatchPattern":"if err := client.GetJSON(ctx, \"/api/workspaces\", &workspaces); err != nil {\n    if strings.Contains(err.Error(), \"401\") { /* re-login path */ }\n    return fmt.Errorf(\"list workspaces: %w\", err)\n}","preventionTips":["Start/verify the server before running login.","Set MULTICA_SERVER_URL from a single source (env file) so all CLI invocations agree.","Wrap CLI calls in scripts and surface the wrapped cause instead of ignoring stderr."],"tags":["cli","network","authentication","go"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}