chenhg5/cc-connect · error

%s: invalid reply context type %T

Error message

%s: invalid reply context type %T

What it means

Feishu Reply type guard: the rctx argument is not the platform's internal replyContext struct, indicating a wiring bug or a foreign reply context (e.g. from another platform adapter). The reply is refused rather than sent to a wrong destination.

Source

Thrown at platform/feishu/feishu.go:3205

					*files = append(*files, core.FileAttachment{MimeType: mt, Data: fileData, FileName: fileBody.FileName})
					sb.WriteString(fmt.Sprintf("%s[%s] %s: [file: %s]\n", indent, ts, senderName, fileBody.FileName))
				}
			}

		case "merge_forward":
			sb.WriteString(fmt.Sprintf("%s[%s] %s: [forwarded messages]\n", indent, ts, senderName))
			p.formatMergeForwardTree(msgID, childrenMap, nameMap, sb, images, files, depth+1)

		default:
			sb.WriteString(fmt.Sprintf("%s[%s] %s: [%s message]\n", indent, ts, senderName, msgType))
		}
	}
}

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

	content = p.resolveMentionsInContent(ctx, rc.chatID, content)
	msgType, msgBody := buildReplyContent(content)

	if !p.shouldUseThreadOrReplyAPI(rc) {
		return p.sendNewMessageToChat(ctx, rc, msgType, msgBody)
	}
	return p.replyMessage(ctx, rc, msgType, msgBody)
}

// Send sends a message. When the original message ID is available, the message
// is sent as a reply (quoting the original) so the conversation stays threaded.
// Falls back to creating a standalone message when no message ID exists.
func (p *Platform) Send(ctx context.Context, rctx any, content string) error {
	rc, ok := rctx.(replyContext)
	if !ok {
		return fmt.Errorf("%s: invalid reply context type %T", p.tag(), rctx)

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Only pass reply contexts obtained from this platform's ReceiveMessage/ReconstructReplyCtx
  2. Check plugin wiring for cross-platform mixing
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at platform/feishu/feishu.go:3205 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/3adecc74d365a7c7. Report an issue: GitHub.