multica-ai/multica · error

update workspace repos: %w

Error message

update workspace repos: %w

What it means

Returned by patchWorkspaceRepos when client.PatchJSON to PATCH /api/workspaces/{workspaceID} with {"repos": [...]} fails. It is the write-side counterpart of error 640: the CLI first GETs the workspace, mutates the repos slice, then PATCHes it back. Failure means the server rejected or never received the update, so the registry is left unchanged.

Source

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

	}
	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
}

func repoCommandClient(cmd *cobra.Command) (*cli.APIClient, string, error) {
	workspaceID, err := requireWorkspaceID(cmd)
	if err != nil {
		return nil, "", err
	}
	client, err := newAPIClient(cmd)
	if err != nil {
		return nil, "", err
	}
	return client, workspaceID, nil
}

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Re-run the command: the GET-modify-PATCH flow is idempotent for add (duplicate URLs are de-duped) and for remove (error 643 reports what is already gone).
  2. Check auth and workspace existence as for error 640 — the same token/base URL is used for the PATCH.
  3. If a 422/validation error is wrapped, inspect the server response body (the APIClient usually includes status/body detail) and fix the offending repo entry.
  4. Retry after transient network failures; if the workspace was deleted mid-flight, re-create or pick another workspace.
Defensive patterns

Strategy: retry

Try / catch

ws, err := patchWorkspaceRepos(ctx, client, workspaceID, repos)
for attempt := 1; err != nil && attempt <= 3; attempt++ {
	// re-fetch to avoid clobbering concurrent edits, then re-apply
	ws, err = fetchRepoWorkspace(ctx, client, workspaceID)
	if err != nil { break }
	ws, err = patchWorkspaceRepos(ctx, client, workspaceID, repos)
}

Prevention

When it happens

Trigger: Calling `multica repo add` or `multica repo remove` where the PATCH returns 401/403/404/422 (e.g. invalid repo payload, workspace deleted between GET and PATCH), the connection drops mid-request, or the server errors while persisting.

Common situations: Concurrent CLI or UI edits that delete or lock the workspace between the GET and PATCH; permissions changed after the initial fetch; server-side validation rejecting a repo entry (empty URL, duplicate); network blips during long-running scripts.

Related errors


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