chenhg5/cc-connect · error

%s: SendVideo: invalid reply context type %T

Error message

%s: SendVideo: invalid reply context type %T

What it means

SendVideo implements the core.VideoSender interface and requires the rctx parameter to be the platform-internal replyContext type. This error is thrown when the type assertion rctx.(replyContext) fails, mirroring error 1233 but for video: the caller passed a reply context that did not originate from this Feishu platform instance.

Source

Thrown at platform/feishu/feishu.go:5544

			"file_key", fileKey, "chat_id", rc.chatID, "format", format)
	}

	return p.sendMediaMessage(ctx, rc, larkim.MsgTypeAudio, audioContent)
}

// SendVideo uploads video bytes to Feishu and sends a native video
// (MsgTypeMedia) message. Implements core.VideoSender.
//
// Feishu's File API only recognises "mp4" as the video file_type, so
// every input is uploaded under that label. Actual playback depends on
// the Feishu client (mp4 H.264 has the broadest support); other
// containers like webm / mkv typically still upload but may render as
// a download tile on some clients. The fallback path to SendFile in
// engine.go preserves at least delivery when this happens.
func (p *Platform) SendVideo(ctx context.Context, rctx any, video []byte, format string, fileName string) error {
	rc, ok := rctx.(replyContext)
	if !ok {
		return fmt.Errorf("%s: SendVideo: invalid reply context type %T", p.tag(), rctx)
	}
	if fileName == "" {
		if format != "" {
			fileName = "video." + format
		} else {
			fileName = "video.mp4"
		}
	}

	var uploadResp *larkim.CreateFileResp
	if err := p.withTransientRetry(ctx, "upload video", func() error {
		return p.withFreshTenantAccessTokenRetry(ctx, "upload video", func(client *lark.Client, options ...larkcore.RequestOptionFunc) error {
			req := larkim.NewCreateFileReqBuilder().
				Body(larkim.NewCreateFileReqBodyBuilder().
					FileType(larkim.FileTypeMp4).
					FileName(fileName).
					File(bytes.NewReader(video)).
					Build()).

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Pass the replyContext value returned by this platform's message/reply APIs as-is
  2. Ensure a single version of the feishu package is in the build (go version -m)
  3. Route video through the engine's reply pipeline rather than constructing contexts manually
  4. Keep per-platform maps if you cache reply contexts generically

Example fix

// before
feishuPlatform.SendVideo(ctx, telegramReplyCtx, video, "mp4", "clip.mp4")
// after
if rc, ok := ctx.Value(feishu.ReplyContextKey).(feishu.ReplyContext); ok {
    feishuPlatform.SendVideo(ctx, rc, video, "mp4", "clip.mp4")
}
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := rctx.(feishu.ReplyContext); !ok { return fmt.Errorf("SendVideo requires a feishu reply context, got %T", rctx) }

Type guard

func asFeishuReplyContext(v any) (feishu.ReplyContext, bool) { rc, ok := v.(feishu.ReplyContext); return rc, ok }

Prevention

When it happens

Trigger: Calling SendVideo with an rctx from another platform adapter, a plain string ID, nil, or a value built by a different build of the feishu package.

Common situations: Generic media-forwarding code storing reply contexts across platforms; dual feishu package versions linked into one binary; custom agent bridging passing the wrong context type.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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