multica-ai/multica · error

get workspace: %w

Error message

get workspace: %w

What it means

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.

Source

Thrown at server/cmd/multica/cmd_repo.go:125

	seen := make(map[string]struct{}, len(raw))
	for _, u := range raw {
		u = strings.TrimSpace(u)
		if u == "" {
			return nil, fmt.Errorf("repository URL cannot be empty")
		}
		if _, ok := seen[u]; ok {
			continue
		}
		seen[u] = struct{}{}
		urls = append(urls, u)
	}
	return urls, nil
}

func fetchRepoWorkspace(ctx context.Context, client *cli.APIClient, workspaceID string) (repoWorkspaceResponse, error) {
	var ws repoWorkspaceResponse
	if err := client.GetJSON(ctx, "/api/workspaces/"+workspaceID, &ws); err != nil {
		return repoWorkspaceResponse{}, fmt.Errorf("get workspace: %w", err)
	}
	if ws.Repos == nil {
		ws.Repos = []workspaceRepo{}
	}
	return ws, nil
}

func patchWorkspaceRepos(ctx context.Context, client *cli.APIClient, workspaceID string, repos []workspaceRepo) (repoWorkspaceResponse, error) {
	var ws repoWorkspaceResponse
	if err := client.PatchJSON(ctx, "/api/workspaces/"+workspaceID, map[string]any{"repos": repos}, &ws); err != nil {
		return repoWorkspaceResponse{}, fmt.Errorf("update workspace repos: %w", err)
	}
	if ws.Repos == nil {
		ws.Repos = []workspaceRepo{}
	}
	return ws, nil
}

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Verify the workspace exists: `multica workspace list` (or GET /api/workspaces) and confirm the ID you passed with --workspace / MULTICA_WORKSPACE_ID.
  2. 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.
  3. If CLI and server versions differ, upgrade the CLI to match the server (`go install`/release download) so repoWorkspaceResponse decodes the current payload.
  4. If the cause is a decode error, inspect the raw response with curl against the same endpoint using the CLI's stored credentials.

Example fix

// before
multica repo add https://github.com/acme/api --workspace does-not-exist

// after
multica workspace list   # copy the real ID
multica repo add https://github.com/acme/api --workspace 01H8Y...
Defensive patterns

Strategy: try-catch

Validate before calling

// Go: verify workspace ID shape before calling the CLI/API
func validWorkspaceID(id string) bool {
	return len(id) > 0 && !strings.ContainsAny(id, " /?#")
}

Try / catch

if _, err := fetchRepoWorkspace(ctx, client, workspaceID); err != nil {
	var status cli.HTTPStatusError // if APIClient exposes status errors
	if errors.As(err, &status) && status.Code == 404 {
		// workspace gone: surface a targeted message
	}
	return fmt.Errorf("resolve workspace %q: %w", workspaceID, err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/8a110141abfdbb59. Report an issue: GitHub.