{"record":{"id":"abdd2e0dee4d88ca","repo":"chenhg5/cc-connect","slug":"matrix-invalid-room-id-in-q","errorCode":null,"errorMessage":"matrix: invalid room ID in %q","messagePattern":"matrix: invalid room ID in %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/matrix/matrix.go","lineNumber":632,"sourceCode":"\tif !strings.HasPrefix(sessionKey, \"matrix:\") {\n\t\treturn nil, fmt.Errorf(\"matrix: invalid session key %q\", sessionKey)\n\t}\n\trest := sessionKey[len(\"matrix:\"):]\n\tif rest == \"\" {\n\t\treturn nil, fmt.Errorf(\"matrix: invalid session key %q\", sessionKey)\n\t}\n\n\t// Find boundary between room ID and optional user ID.\n\t// User IDs start with @, so \":@\" only appears at the roomID:userID boundary.\n\tvar roomIDStr string\n\tif idx := strings.Index(rest, \":@\"); idx >= 0 {\n\t\troomIDStr = rest[:idx]\n\t} else {\n\t\troomIDStr = rest\n\t}\n\n\tif !strings.HasPrefix(roomIDStr, \"!\") {\n\t\treturn nil, fmt.Errorf(\"matrix: invalid room ID in %q\", sessionKey)\n\t}\n\treturn replyContext{roomID: id.RoomID(roomIDStr)}, nil\n}\n\n// --- Internal helpers ---\n\nfunc (p *Platform) buildSessionKey(roomID id.RoomID, sender id.UserID) string {\n\tif p.shareSessionInChannel {\n\t\treturn fmt.Sprintf(\"matrix:%s\", roomID)\n\t}\n\treturn fmt.Sprintf(\"matrix:%s:%s\", roomID, sender)\n}\n\nfunc (p *Platform) isDMRoom(ctx context.Context, roomID id.RoomID) bool {\n\tclient := p.getClient()\n\tif client == nil {\n\t\treturn false\n\t}","sourceCodeStart":614,"sourceCodeEnd":650,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/matrix/matrix.go#L614-L650","documentation":"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.","triggerScenarios":"Thrown at platform/matrix/matrix.go:632 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate the session from a live message","Verify the stored session key was not truncated"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}