{"record":{"id":"6f30961fc59eca3d","repo":"livekit/livekit","slug":"invalid-router-message","errorCode":null,"errorMessage":"invalid router message","messagePattern":"invalid router message","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/routing/errors.go","lineNumber":28,"sourceCode":"// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage routing\n\nimport (\n\t\"errors\"\n)\n\nvar (\n\tErrNotFound             = errors.New(\"could not find object\")\n\tErrIPNotSet             = errors.New(\"ip address is required and not set\")\n\tErrHandlerNotDefined    = errors.New(\"handler not defined\")\n\tErrIncorrectRTCNode     = errors.New(\"current node isn't the RTC node for the room\")\n\tErrNodeNotFound         = errors.New(\"could not locate the node\")\n\tErrNodeLimitReached     = errors.New(\"reached configured limit for node\")\n\tErrInvalidRouterMessage = errors.New(\"invalid router message\")\n\tErrChannelClosed        = errors.New(\"channel closed\")\n\tErrChannelFull          = errors.New(\"channel is full\")\n\n\t// errors when starting signal connection\n\tErrRequestChannelClosed       = errors.New(\"request channel closed\")\n\tErrCouldNotMigrateParticipant = errors.New(\"could not migrate participant\")\n\tErrClientInfoNotSet           = errors.New(\"client info not set\")\n)\n","sourceCodeStart":10,"sourceCodeEnd":37,"githubUrl":"https://github.com/livekit/livekit/blob/ee45c3f0b1a83bf4352dbccb6607ebf70b2a5de6/pkg/routing/errors.go#L10-L37","documentation":"ErrInvalidRouterMessage is a sentinel error in pkg/routing indicating that a message received by the router does not conform to the expected router message format. The routing layer validates incoming messages before dispatching them to handlers, and any message that cannot be parsed or does not match the router's expected shape is rejected with this error. It signals a protocol/contract mismatch between sender and receiver.","triggerScenarios":"Publishing or routing a message through the routing layer whose payload is nil, malformed, or lacks required fields expected by the router's message handler; sending an unregistered/unknown message type into the router.","commonSituations":"Version skew between LiveKit nodes where one node sends a message shape another doesn't understand; custom integrations hand-crafting router messages; serialization/deserialization bugs producing empty or partially populated messages.","solutions":["Verify the message is fully constructed and serialized with the expected protobuf type before publishing it to the router","Ensure all nodes run compatible LiveKit versions so message schemas match","Check that the message is being sent to the correct routing topic/handler","Log the offending message contents at the send site to find the field that is missing or invalid"],"exampleFix":"// before\nrouter.Publish(ctx, nil)\n// after\nmsg := &livekit.RouterMessage{ /* populate required fields */ }\nif msg == nil || proto.Size(msg) == 0 {\n    return errors.New(\"refusing to publish empty router message\")\n}\nrouter.Publish(ctx, msg)","handlingStrategy":"validation","validationCode":"func validRouterMessage(msg *livekit.RouterMessage) bool {\n    return msg != nil && proto.Size(msg) > 0\n}\nif !validRouterMessage(msg) {\n    return errors.New(\"refusing to publish empty/invalid router message\")\n}","typeGuard":"func isValidRouterMessage(m interface{}) bool {\n    m, ok := m.(*livekit.RouterMessage)\n    return ok && m != nil\n}","tryCatchPattern":null,"preventionTips":["Keep all nodes on the same LiveKit version to avoid schema skew","Validate messages at the send site before publishing","Pin protobuf definitions shared between sender and receiver"],"tags":["routing","protocol","message-validation","livekit"],"backgroundTag":"invalid-router-message","analyzedSha":"ee45c3f0b1a83bf4352dbccb6607ebf70b2a5de6","analyzedAt":"2026-09-02T03:56:08.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}