chenhg5/cc-connect · error

%s: patch message: %w

Error message

%s: patch message: %w

What it means

Wrapped failure from patching an existing Feishu card message (larkim PatchMessage) with new card JSON, where %s is the retry operation label; fires when the patch API call fails after transient-retry and fresh-tenant-access-token retry wrappers.

Source

Thrown at platform/feishu/feishu.go:5341

	h.mu.Unlock()
	if cardID != "" {
		return p.updateCardEntity(ctx, h, cardJSON)
	}
	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()

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Rely on retries; check the message still exists (not recalled)
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at platform/feishu/feishu.go:5341 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/29e681b1c88d1c43. Report an issue: GitHub.