chenhg5/cc-connect · error

%s: patch message code=%d msg=%s

Error message

%s: patch message code=%d msg=%s

What it means

The Patch API answered with a Lark application error (non-zero code) while patching the card message. Code and message are embedded — frequent causes are message already deleted or card rate limiting.

Source

Thrown at platform/feishu/feishu.go:5344

	}
	return p.patchCardMessage(ctx, h.messageID, cardJSON)
}

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

// updateCardEntity performs a full-card replacement on a cardkit-v1 entity via
// PUT /open-apis/cardkit/v1/cards/{card_id}. Required for messages that were
// sent as card_id references (rich-mode path) — Im.Message.Patch does not
// affect the rendered content of such messages.
//
// Reuses h.sequence as the monotonic ordering counter (shared with
// streamRichCardText so any sequence on any element/card is monotonic).
func (p *Platform) updateCardEntity(ctx context.Context, h *feishuPreviewHandle, cardJSON string) error {
	h.mu.Lock()
	if h.cardID == "" {
		h.mu.Unlock()
		return fmt.Errorf("%s: updateCardEntity: cardID not set", p.tag())

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Throttle streaming frames on rate-limit codes
  2. Check message_id validity and im permissions
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at platform/feishu/feishu.go:5344 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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