chenhg5/cc-connect · error

%s: updateCardEntity: cardID not set

Error message

%s: updateCardEntity: cardID not set

What it means

updateCardEntity precondition guard: the preview handle's cardID is empty, meaning the message was sent as inline card JSON (not a card_id reference), so the cardkit entity PUT does not apply — Im.Message.Patch must be used instead.

Source

Thrown at platform/feishu/feishu.go:5362

				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())
	}
	h.sequence++
	cardID := h.cardID
	seq := h.sequence
	h.mu.Unlock()

	apiPath := fmt.Sprintf("/open-apis/cardkit/v1/cards/%s", cardID)
	body := map[string]any{
		"card": map[string]any{
			"type": "card_json",
			"data": cardJSON,
		},
		"sequence": seq,
	}
	var apiResp *larkcore.ApiResp
	if err := p.withFreshTenantAccessTokenRetry(ctx, "update card entity", func(client *lark.Client, options ...larkcore.RequestOptionFunc) error {
		var err error
		apiResp, err = client.Put(ctx, apiPath, body, larkcore.AccessTokenTypeTenant, options...)

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Call patchCardMessage for inline-card messages
  2. Only call updateCardEntity when the handle carries a cardID
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at platform/feishu/feishu.go:5362 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/5c017c9714e20973. Report an issue: GitHub.