multica-ai/multica · error

list workspaces: %w

Error message

list workspaces: %w

What it means

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.

Source

Thrown at server/cmd/multica/cmd_login.go:112

		return err
	}
	if cfg.Token == "" {
		return fmt.Errorf("not authenticated")
	}
	if cfg.ServerURL == "" {
		return fmt.Errorf("server URL not configured")
	}

	client := cli.NewAPIClient(normalizeAPIBaseURL(cfg.ServerURL), "", cfg.Token)
	ctx, cancel := cli.APIContext(context.Background())
	defer cancel()

	var workspaces []struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	}
	if err := client.GetJSON(ctx, "/api/workspaces", &workspaces); err != nil {
		return fmt.Errorf("list workspaces: %w", err)
	}

	if len(workspaces) == 0 {
		var err error
		workspaces, err = waitForWorkspaceCreation(cmd, client)
		if err != nil {
			return err
		}
		if len(workspaces) == 0 {
			fmt.Fprintln(os.Stderr, "\nNo workspaces found.")
			return nil
		}
	}

	// Set default workspace if not set.
	if cfg.WorkspaceID == "" {
		cfg.WorkspaceID = workspaces[0].ID
	}

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Check that the server is running and reachable: curl the /api/workspaces endpoint printed in the error's ServerURL.
  2. Verify the configured server URL (config file or MULTICA_SERVER_URL env) matches where the server actually listens.
  3. Re-run login without a stale token so a fresh one is issued; inspect cfg.Token in the CLI config.
  4. If the wrapped error mentions x509/TLS, import the server certificate or use a proper CA-signed cert.

Example fix

// before
MULTICA_SERVER_URL=http://localhost:9999 multica login
// -> list workspaces: GET "http://localhost:9999/api/workspaces": connection refused

// after
multica server &   # start server on its real port (e.g. 8080)
MULTICA_SERVER_URL=http://localhost:8080 multica login
Defensive patterns

Strategy: try-catch

Validate before calling

if cfg.ServerURL == "" { return fmt.Errorf("server URL not configured") }
if err := healthCheck(cfg.ServerURL); err != nil { return fmt.Errorf("server unreachable: %w", err) }

Try / catch

if err := client.GetJSON(ctx, "/api/workspaces", &workspaces); err != nil {
    if strings.Contains(err.Error(), "401") { /* re-login path */ }
    return fmt.Errorf("list workspaces: %w", err)
}

Prevention

When it happens

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

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

Related errors


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