multica-ai/multica · error

create workspace: %w

Error message

create workspace: %w

What it means

The POST /api/workspaces issued by `multica workspace create` failed. Flag-level validation already passed, so the wrapped error is server- or transport-side: duplicate slug (400/409), auth failure (401), permission limits, or an unreachable server.

Source

Thrown at server/cmd/multica/cmd_workspace.go:347

func runWorkspaceCreate(cmd *cobra.Command, _ []string) error {
	body, err := buildWorkspaceCreateBody(cmd)
	if err != nil {
		return err
	}

	client, err := newAPIClient(cmd)
	if err != nil {
		return err
	}
	client.WorkspaceID = ""

	ctx, cancel := cli.APIContext(context.Background())
	defer cancel()

	var ws map[string]any
	if err := client.PostJSON(ctx, "/api/workspaces", body, &ws); err != nil {
		return fmt.Errorf("create workspace: %w", err)
	}
	return printWorkspace(cmd, ws)
}

// resolveWorkspaceByIDOrSlug looks up a workspace in the caller's accessible
// list by full UUID, slug (case-insensitive), or short UUID prefix (≥4 hex
// chars). The matching order is exact UUID → exact slug → prefix, so a slug
// that happens to be a hex string can never be shadowed by a colliding UUID
// prefix. Returns an error if no workspace matches, which doubles as the
// "access denied / does not exist" check — the server only returns workspaces
// the user is a member of, so a match implies access.
func resolveWorkspaceByIDOrSlug(workspaces []workspaceSummary, target string) (workspaceSummary, error) {
	target = strings.TrimSpace(target)
	if target == "" {
		return workspaceSummary{}, fmt.Errorf("workspace id, slug, or id prefix is required")
	}
	// Slug comparison is case-insensitive (slugs are stored lowercase on the
	// server, but tolerate user-typed uppercase). UUIDs are also case-

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Read the wrapped error: duplicate slug → pick a different --slug or use the existing workspace (`multica workspace list`).
  2. 401 → `multica login` and retry.
  3. Connection error → verify the server URL / daemon status, then retry.
  4. Plan/limit errors → remove unused workspaces or raise the limit.
Defensive patterns

Strategy: try-catch

Validate before calling

multica workspace list --output json 2>/dev/null | grep -q "\"$SLUG\"" && echo 'slug already in use: create will fail'

Try / catch

out=$(multica workspace create --name "$NAME" --slug "$SLUG" 2>&1) || { case "$out" in *slug*|*exist*|*409*|*400*) echo 'slug taken: choose another'; exit 1 ;; *401*|*unauthorized*) multica login ;; *) echo "$out"; exit 1 ;; esac; }

Prevention

When it happens

Trigger: Creating a workspace whose slug already exists on the account, running with an expired token, or the server being down at request time. Note client.WorkspaceID is cleared first so the request goes to the global endpoint.

Common situations: Re-running a create script after a partial failure (slug already taken), team plan workspace-count limits, token expired between commands.

Related errors


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