chenhg5/cc-connect · error

%s: refresh card code=%d msg=%s

Error message

%s: refresh card code=%d msg=%s

What it means

Raised when the Lark Im.Message.Patch call completes but resp.Success() is false, i.e. Feishu returned an application-level error. The Feishu business code and message are embedded so the exact API failure (e.g. permission, invalid card JSON) can be identified. Same retry wrapping applies as transport errors.

Source

Thrown at platform/feishu/card.go:81

	if msgID == "" {
		return fmt.Errorf("%s: no tracked card messageID for session %q", p.tag(), sessionKey)
	}

	cardJSON := renderCard(card, sessionKey)
	req := larkim.NewPatchMessageReqBuilder().
		MessageId(msgID).
		Body(larkim.NewPatchMessageReqBodyBuilder().
			Content(cardJSON).
			Build()).
		Build()
	return p.withTransientRetry(ctx, "refresh card", func() error {
		return p.withFreshTenantAccessTokenRetry(ctx, "refresh card", func(client *lark.Client, options ...larkcore.RequestOptionFunc) error {
			resp, err := client.Im.Message.Patch(ctx, req, options...)
			if err != nil {
				return fmt.Errorf("%s: refresh card: %w", p.tag(), err)
			}
			if !resp.Success() {
				return fmt.Errorf("%s: refresh card code=%d msg=%s", p.tag(), resp.Code, resp.Msg)
			}
			return nil
		})
	})
}

// renderCardMap converts a core.Card into the Feishu Interactive Card map
// using the v1 format. Used both for message API (via renderCard) and
// callback responses (CardActionTriggerResponse).
func renderCardMap(card *core.Card, sessionKey string) map[string]any {
	result := map[string]any{
		"config": map[string]any{
			"wide_screen_mode": true,
		},
	}
	if card == nil {
		return result
	}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Look up the embedded code=%d in Feishu's error-code docs and fix the specific cause.
  2. Ensure the app has im:message:update (patch) scope and the bot is still in the chat.
  3. Reduce card payload size if code indicates card too large or invalid.
  4. Verify message_id validity; skip refresh if the message was recalled.
Defensive patterns

Strategy: try-catch

Try / catch

var feishuErr *larkcore.APIError
if errors.As(err, &feishuErr) {
    slog.Error("feishu patch rejected", "code", feishuErr.Code, "msg", feishuErr.Msg)
}

Prevention

When it happens

Trigger: Patch request reaches Feishu but is rejected: invalid card JSON schema, bot lacks im:message permission for update, message_id not found (code 230002), or rate-limit/business code returned in resp.Code.

Common situations: Insufficient scopes on the Feishu app after an app config change; card content exceeding Feishu size limits during long streams; patching a message whose chat the bot was removed from.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/40cdc8d37880bb3e. Report an issue: GitHub.