chenhg5/cc-connect · error

matrix: invalid reply context type %T

Error message

matrix: invalid reply context type %T

What it means

Type-assertion guard in Matrix Reply: the rctx passed by the engine is not the platform's internal replyContext struct (nil or wrong type), indicating the reply context was fabricated or corrupted rather than produced by this platform's message handler.

Source

Thrown at platform/matrix/matrix.go:406

		return fmt.Errorf("matrix: not connected")
	}

	// Try E2EE path first (only available when built with goolm tag)
	if handled, err := p.tryEncryptAndSend(ctx, client, roomID, evtType, content); handled {
		return err
	}

	_, err := client.SendMessageEvent(ctx, roomID, evtType, content)
	if err != nil {
		return fmt.Errorf("matrix: send: %w", err)
	}
	return nil
}

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

	parsed := format.RenderMarkdown(content, true, false)
	parsed.Body = content
	if content != "" {
		parsed.RelatesTo = &event.RelatesTo{}
		parsed.RelatesTo.SetReplyTo(rc.messageID)
	}

	return p.sendRoomEvent(ctx, rc.roomID, event.EventMessage, &parsed)
}

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

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Pass reply contexts from this platform's messages or ReconstructReplyCtx
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at platform/matrix/matrix.go:406 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/28a5ff49a8f06992. Report an issue: GitHub.