chenhg5/cc-connect · error
matrix: invalid room ID in %q
Error message
matrix: invalid room ID in %q
What it means
Validation guard in ReconstructReplyCtx: after stripping the `matrix:` prefix and optional `:@userID` suffix, the room ID portion does not start with `!` as Matrix room IDs must, so the session key encodes a malformed room identifier.
Source
Thrown at platform/matrix/matrix.go:632
if !strings.HasPrefix(sessionKey, "matrix:") {
return nil, fmt.Errorf("matrix: invalid session key %q", sessionKey)
}
rest := sessionKey[len("matrix:"):]
if rest == "" {
return nil, fmt.Errorf("matrix: invalid session key %q", sessionKey)
}
// Find boundary between room ID and optional user ID.
// User IDs start with @, so ":@" only appears at the roomID:userID boundary.
var roomIDStr string
if idx := strings.Index(rest, ":@"); idx >= 0 {
roomIDStr = rest[:idx]
} else {
roomIDStr = rest
}
if !strings.HasPrefix(roomIDStr, "!") {
return nil, fmt.Errorf("matrix: invalid room ID in %q", sessionKey)
}
return replyContext{roomID: id.RoomID(roomIDStr)}, nil
}
// --- Internal helpers ---
func (p *Platform) buildSessionKey(roomID id.RoomID, sender id.UserID) string {
if p.shareSessionInChannel {
return fmt.Sprintf("matrix:%s", roomID)
}
return fmt.Sprintf("matrix:%s:%s", roomID, sender)
}
func (p *Platform) isDMRoom(ctx context.Context, roomID id.RoomID) bool {
client := p.getClient()
if client == nil {
return false
}View on GitHub (pinned to 4000b2338a)
Solutions
- Regenerate the session from a live message
- Verify the stored session key was not truncated
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at platform/matrix/matrix.go:632 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/abdd2e0dee4d88ca.
Report an issue: GitHub.