{"record":{"id":"8a110141abfdbb59","repo":"multica-ai/multica","slug":"get-workspace-w","errorCode":null,"errorMessage":"get workspace: %w","messagePattern":"get workspace: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_repo.go","lineNumber":125,"sourceCode":"\tseen := make(map[string]struct{}, len(raw))\n\tfor _, u := range raw {\n\t\tu = strings.TrimSpace(u)\n\t\tif u == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"repository URL cannot be empty\")\n\t\t}\n\t\tif _, ok := seen[u]; ok {\n\t\t\tcontinue\n\t\t}\n\t\tseen[u] = struct{}{}\n\t\turls = append(urls, u)\n\t}\n\treturn urls, nil\n}\n\nfunc fetchRepoWorkspace(ctx context.Context, client *cli.APIClient, workspaceID string) (repoWorkspaceResponse, error) {\n\tvar ws repoWorkspaceResponse\n\tif err := client.GetJSON(ctx, \"/api/workspaces/\"+workspaceID, &ws); err != nil {\n\t\treturn repoWorkspaceResponse{}, fmt.Errorf(\"get workspace: %w\", err)\n\t}\n\tif ws.Repos == nil {\n\t\tws.Repos = []workspaceRepo{}\n\t}\n\treturn ws, nil\n}\n\nfunc patchWorkspaceRepos(ctx context.Context, client *cli.APIClient, workspaceID string, repos []workspaceRepo) (repoWorkspaceResponse, error) {\n\tvar ws repoWorkspaceResponse\n\tif err := client.PatchJSON(ctx, \"/api/workspaces/\"+workspaceID, map[string]any{\"repos\": repos}, &ws); err != nil {\n\t\treturn repoWorkspaceResponse{}, fmt.Errorf(\"update workspace repos: %w\", err)\n\t}\n\tif ws.Repos == nil {\n\t\tws.Repos = []workspaceRepo{}\n\t}\n\treturn ws, nil\n}\n","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_repo.go#L107-L143","documentation":"Returned by fetchRepoWorkspace in the multica CLI when client.GetJSON against GET /api/workspaces/{workspaceID} fails. The wrapped error is produced by the shared cli.APIClient helper and can be a connection failure, a non-2xx HTTP status (e.g. 401/403/404), or a response-body decode failure. Every repo subcommand (add/remove/list) funnels through this helper, so any workspace-resolution problem surfaces as this exact message.","triggerScenarios":"Running `multica repo add/remove/list` with a workspace ID that does not exist (404), an expired or missing API token (401/403), the multica server not running or unreachable at the configured base URL, or a workspace payload whose shape no longer matches repoWorkspaceResponse after a version skew between CLI and server.","commonSituations":"Typing or copy-pasting a wrong workspace ID; pointing the CLI at a stale server URL after the deployment moved; token expired since the last CLI login; server upgraded with breaking API changes while the old CLI binary is still installed.","solutions":["Verify the workspace exists: `multica workspace list` (or GET /api/workspaces) and confirm the ID you passed with --workspace / MULTICA_WORKSPACE_ID.","Check connectivity and auth: confirm the server base URL configured for the CLI is reachable and re-authenticate (`multica login` or equivalent) so GetJSON gets a valid token.","If CLI and server versions differ, upgrade the CLI to match the server (`go install`/release download) so repoWorkspaceResponse decodes the current payload.","If the cause is a decode error, inspect the raw response with curl against the same endpoint using the CLI's stored credentials."],"exampleFix":"// before\nmultica repo add https://github.com/acme/api --workspace does-not-exist\n\n// after\nmultica workspace list   # copy the real ID\nmultica repo add https://github.com/acme/api --workspace 01H8Y...","handlingStrategy":"try-catch","validationCode":"// Go: verify workspace ID shape before calling the CLI/API\nfunc validWorkspaceID(id string) bool {\n\treturn len(id) > 0 && !strings.ContainsAny(id, \" /?#\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := fetchRepoWorkspace(ctx, client, workspaceID); err != nil {\n\tvar status cli.HTTPStatusError // if APIClient exposes status errors\n\tif errors.As(err, &status) && status.Code == 404 {\n\t\t// workspace gone: surface a targeted message\n\t}\n\treturn fmt.Errorf(\"resolve workspace %q: %w\", workspaceID, err)\n}","preventionTips":["Always source workspace IDs from `multica workspace list` output rather than typing them.","Keep CLI and server versions in lockstep to avoid decode mismatches.","Scripts should pre-flight GET /api/workspaces/{id} and fail fast with a clear message."],"tags":["go","cli","http","workspace","api-client"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}