chenhg5/cc-connect · error

weibo: invalid reply context type: %T

Error message

weibo: invalid reply context type: %T

What it means

A type assertion in sendMessage expected the reply context passed by the engine to be the weibo platform's internal replyContext struct, but it received some other type. This is a programming/wiring error (wrong platform's context reused across platforms), not a user-input problem.

Solutions

  1. Ensure the engine always passes the replyContext originally produced by the weibo platform's message handler back to sendMessage
  2. If contexts can originate elsewhere (cron/proactive sends), reconstruct a proper replyContext via the platform's ReconstructReplyCtx instead of passing a foreign type
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at platform/weibo/weibo.go:523 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/8fe294c867fbddd3. Report an issue: GitHub.

Appendix: source

Thrown at platform/weibo/weibo.go:523

	return text, images, files
}

// --- Sending ---

type sendPayload struct {
	ToUserID  string             `json:"toUserId"`
	Text      string             `json:"text"`
	MessageID string             `json:"messageId"`
	ChunkID   int                `json:"chunkId"`
	Done      bool               `json:"done"`
	Input     []messageInputItem `json:"input,omitempty"`
}

func (p *Platform) sendMessage(rctx any, content string) error {
	rc, ok := rctx.(replyContext)
	if !ok {
		return fmt.Errorf("weibo: invalid reply context type: %T", rctx)
	}

	chunks := splitText(content, maxTextPerChunk)
	msgID := fmt.Sprintf("out-%s-%d", rc.fromUserID, time.Now().UnixMilli())

	for i, chunk := range chunks {
		env := map[string]any{
			"type": "send_message",
			"payload": sendPayload{
				ToUserID:  rc.fromUserID,
				Text:      chunk,
				MessageID: msgID,
				ChunkID:   i,
				Done:      i == len(chunks)-1,
			},
		}
		if err := p.writeWS(env); err != nil {
			return err

View on GitHub (pinned to 4000b2338a)