chenhg5/cc-connect · error

matrix: invalid preview handle type %T

Error message

matrix: invalid preview handle type %T

What it means

Type-assertion guard in Matrix UpdateMessage: the previewHandle is not the platform's internal replyContext struct, meaning the streaming-preview handle was not created by this platform's preview mechanism.

Source

Thrown at platform/matrix/matrix.go:589

			case <-ctx.Done():
				return
			case <-ticker.C:
				c := p.getClient()
				if c == nil {
					return
				}
				_, _ = c.UserTyping(ctx, rc.roomID, true, 30*time.Second)
			}
		}
	}()

	return func() { close(done) }
}

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

	parsed := format.RenderMarkdown(content, true, false)
	parsed.Body = content

	// Copy the new content for m.replace relation
	newContent := parsed
	newContent.Mentions = nil

	parsed.NewContent = &newContent
	parsed.RelatesTo = &event.RelatesTo{
		Type:    event.RelReplace,
		EventID: rc.messageID,
	}
	parsed.Body = "* " + content

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

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Only pass handles returned by this platform's send path
Defensive patterns

Strategy: type-guard

When it happens

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