chenhg5/cc-connect · error

%s: SendImage: invalid reply context type %T

Error message

%s: SendImage: invalid reply context type %T

What it means

SendImage received a reply context that is not the feishu replyContext struct — a type-guard failure meaning an internal caller passed the wrong rctx shape. The offending dynamic type is reported via %T.

Source

Thrown at platform/feishu/feishu.go:3266

	if strings.TrimSpace(footer) == "" || strings.Contains(content, `<at user_id=`) || strings.Contains(content, `<at id=`) {
		if strings.TrimSpace(footer) != "" {
			content += "\n\n" + footer
		}
		return p.Send(ctx, rctx, content)
	}
	processedBody := sanitizeMarkdownURLs(preprocessFeishuMarkdown(content))
	processedFooter := sanitizeMarkdownURLs(preprocessFeishuMarkdown(footer))
	cardJSON := buildCardJSONWithStatusFooter(processedBody, processedFooter)
	if p.shouldUseThreadOrReplyAPI(rc) {
		return p.replyMessage(ctx, rc, larkim.MsgTypeInteractive, cardJSON)
	}
	return p.sendNewMessageToChat(ctx, rc, larkim.MsgTypeInteractive, cardJSON)
}

func (p *Platform) SendImage(ctx context.Context, rctx any, img core.ImageAttachment) error {
	rc, ok := rctx.(replyContext)
	if !ok {
		return fmt.Errorf("%s: SendImage: invalid reply context type %T", p.tag(), rctx)
	}

	imageKey, err := p.uploadImageKey(ctx, img.Data)
	if err != nil {
		return err
	}
	imageContent, err := (&larkim.MessageImage{ImageKey: imageKey}).String()
	if err != nil {
		return fmt.Errorf("%s: build image message: %w", p.tag(), err)
	}

	return p.sendMediaMessage(ctx, rc, larkim.MsgTypeImage, imageContent)
}

func (p *Platform) uploadImageKey(ctx context.Context, data []byte) (string, error) {
	var uploadResp *larkim.CreateImageResp
	if err := p.withTransientRetry(ctx, "upload image", func() error {
		return p.withFreshTenantAccessTokenRetry(ctx, "upload image", func(client *lark.Client, options ...larkcore.RequestOptionFunc) error {

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Pass a reply context produced by the Feishu platform itself
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at platform/feishu/feishu.go:3266 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/9302d85dc215d732. Report an issue: GitHub.