{"record":{"id":"f6deac31aab7139d","repo":"tracel-ai/burn","slug":"received-a-message-that-wasn-t-a-tensor-request","errorCode":null,"errorMessage":"Received a message that wasn't a tensor request! {msg:?}","messagePattern":"Received a message that wasn't a tensor request! (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-communication/src/external_comm.rs","lineNumber":244,"sourceCode":"        }\n    }\n\n    /// Handle incoming connections for downloading tensors.\n    pub(crate) async fn handle_data_channel(\n        &self,\n        mut channel: <P::Server as ProtocolServer>::Channel,\n    ) {\n        log::info!(\"[Data Handler] New connection for download.\");\n\n        while !self.cancel_token.is_cancelled() {\n            match channel.recv().await {\n                Ok(message) => {\n                    if let Some(msg) = message {\n                        let bytes = msg.data;\n                        let msg: ExternalCommMessage = rmp_serde::from_slice(&bytes)\n                            .expect(\"Can deserialize messages from the websocket.\");\n                        let ExternalCommMessage::TensorRequest(transfer_id) = msg else {\n                            panic!(\"Received a message that wasn't a tensor request! {msg:?}\");\n                        };\n\n                        let bytes = self.get_exposed_tensor_bytes(transfer_id).await.unwrap();\n\n                        channel.send(Message::new(bytes)).await.unwrap();\n                    } else {\n                        log::info!(\"Closed connection\");\n                        return;\n                    }\n                }\n                Err(err) => panic!(\"Failed to receive message from websocket: {err:?}\"),\n            };\n        }\n        log::info!(\"[Data Service] Closing connection for download.\");\n    }\n}\n","sourceCodeStart":226,"sourceCodeEnd":261,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-communication/src/external_comm.rs#L226-L261","documentation":"The server-side data-channel handler expects every incoming message on the 'data' channel to be an `ExternalCommMessage::TensorRequest`. Any other valid message triggers this panic, meaning the connected peer is using the data channel for something other than download requests.","triggerScenarios":"A client sending TensorData or other ExternalCommMessage variants over the 'data' subprotocol instead of TensorRequest; two clients both opening data channels as servers; protocol/version mismatch causing a different variant to deserialize first.","commonSituations":"Miswired client code that uploads tensors on the data channel; a burn version mismatch where the message enum layout differs; a proxy duplicating messages across channels.","solutions":["Send only `ExternalCommMessage::TensorRequest` on the 'data' channel from the downloading side.","Align burn-communication versions between client and server so the enum variants match.","Inspect the {msg:?} debug output in the panic to identify which variant the peer actually sent."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Server side: ignore rather than panic on unexpected variants\nmatch msg {\n    ExternalCommMessage::TensorRequest(id) => serve(id).await,\n    other => log::warn!(\"ignoring non-request message: {other:?}\"),\n}","typeGuard":"fn as_tensor_request(msg: ExternalCommMessage) -> Option<TransferId> {\n    match msg { ExternalCommMessage::TensorRequest(id) => Some(id), _ => None }\n}","tryCatchPattern":null,"preventionTips":["Only use the 'data' subprotocol channel for TensorRequest traffic","Match burn-communication versions on both peers","Wrap handler panics with a catch_unwind/task boundary so one bad message doesn't kill the server"],"tags":["rust","burn","websocket","protocol"],"backgroundTag":"unexpected-message-type","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}