multica-ai/multica · error

read chat: %w

Error message

read chat: %w

What it means

fetchChatRead wraps any failure of the chat-read HTTP request (GET basePath with optional ?id=<thread>&limit=<n>&before=<cursor>) as 'read chat: %w'. The wrapped error is the transport/status/decode failure from client.GetJSON — the chat endpoint returned non-2xx or the request never completed.

Source

Thrown at server/cmd/multica/cmd_chat.go:110

	q := url.Values{}
	if threadID != "" {
		q.Set("id", threadID)
	}
	if limit > 0 {
		q.Set("limit", strconv.Itoa(limit))
	}
	if before != "" {
		q.Set("before", before)
	}
	path := basePath
	if encoded := q.Encode(); encoded != "" {
		path += "?" + encoded
	}

	var resp map[string]any
	if err := client.GetJSON(ctx, path, &resp); err != nil {
		return nil, fmt.Errorf("read chat: %w", err)
	}
	return resp, nil
}

// renderChatRead prints the response as JSON (default) or a table. The overview
// table adds the thread columns so the agent can pick a thread_id to drill into.
func renderChatRead(cmd *cobra.Command, resp map[string]any, overview bool) error {
	output, _ := cmd.Flags().GetString("output")
	if output != "table" {
		return cli.PrintJSON(os.Stdout, resp)
	}
	if note := strVal(resp, "note"); note != "" {
		fmt.Fprintln(os.Stdout, note)
		return nil
	}
	msgs, _ := resp["messages"].([]any)
	var headers []string
	if overview {

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Inspect the wrapped error for the HTTP status: 404 → thread id wrong or deleted; 400 → bad limit/before value; 401 → re-auth.
  2. Re-run without --before/--limit to confirm the base listing works, then re-add paging params one at a time.
  3. Verify the thread id exists in the overview listing (`chat read` without --id).

Example fix

# before
multica chat read --id <stale-thread-id> --before <old-cursor>
# after
multica chat read --id <thread-id-from-listing>
Defensive patterns

Strategy: retry

Validate before calling

# confirm the thread exists before reading with paging cursors
multica chat read --output json | jq -e --arg id "$THREAD" '.messages[]? | select(.thread_id == $id)' >/dev/null \
  || { echo "thread $THREAD not found; refresh thread ids" >&2; exit 2; }

Try / catch

out, err := fetchChatRead(...)
if err != nil && strings.Contains(err.Error(), "read chat") {
    if statusIs(err, 401, 403) { reauth(); out, err = fetchChatRead(...) } // one retry after auth
    if statusIs(err, 503)     { out, err = fetchChatRead(...) }          // one retry after backoff
}

Prevention

When it happens

Trigger: Running `multica chat read` (or a thread variant) with an invalid/expired thread id, a malformed --before cursor, limit out of the server's accepted range, an unreachable server, or an unauthenticated session.

Common situations: Cursor (--before) copied from an older API version after pagination format changed; thread deleted between listing and read; dev server restarted losing in-memory state; stale auth token.

Related errors


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