{"record":{"id":"28d04ad0d2bf291d","repo":"spacedriveapp/spacedrive","slug":"failed-to-serialize-sync-request-28d04a","errorCode":null,"errorMessage":"Failed to serialize sync request: {}","messagePattern":"Failed to serialize sync request: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"core/src/service/network/transports/sync.rs","lineNumber":261,"sourceCode":"\t\t\t\tuse crate::service::network::core::event_loop::EventLoopCommand;\n\t\t\t\tlet _ = cmd_sender.send(EventLoopCommand::TrackOutboundConnection {\n\t\t\t\t\tnode_id,\n\t\t\t\t\tconn: new_conn.clone(),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tnew_conn\n\t\t};\n\n\t\t// Open bidirectional stream\n\t\tlet (mut send, mut recv) = conn\n\t\t\t.open_bi()\n\t\t\t.await\n\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to open bidirectional stream: {}\", e))?;\n\n\t\t// Serialize and send request\n\t\tlet req_bytes = serde_json::to_vec(&request)\n\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to serialize sync request: {}\", e))?;\n\n\t\tlet len = req_bytes.len() as u32;\n\t\tsend.write_all(&len.to_be_bytes())\n\t\t\t.await\n\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to send length: {}\", e))?;\n\t\tsend.write_all(&req_bytes)\n\t\t\t.await\n\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to send request: {}\", e))?;\n\n\t\t// Properly close send stream\n\t\tsend.finish()\n\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to finish stream: {}\", e))?;\n\n\t\tdebug!(\"Sync request sent, waiting for response...\");\n\n\t\t// Read response with timeout\n\t\tlet result = timeout(Duration::from_secs(60), async {\n\t\t\tlet mut len_buf = [0u8; 4];","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/core/src/service/network/transports/sync.rs#L243-L279","documentation":"serde_json::to_vec(&request) failed while serializing the outgoing SyncMessage. SyncMessage variants are plain data, so this only happens when a variant contains a type whose Serialize impl can fail (for example a map with non-string keys) or the enum shape changed incompatibly. In practice this is a programming or version-skew bug, not an environmental failure.","triggerScenarios":"A newly added SyncMessage variant carries a non-JSON-serializable field; two peers built from different commits exchange message shapes the sender cannot encode.","commonSituations":"Almost never seen in production; appears during protocol development right after editing the SyncMessage enum.","solutions":["Inspect the SyncMessage variant being sent for types whose Serialize can error and replace them with JSON-safe types","Add a unit test that round-trips every SyncMessage variant through serde_json::to_vec and from_slice","Gate protocol changes behind a version handshake so mismatched peers reject cleanly instead of failing mid-serialize"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match serde_json::to_vec(&request) {\n    Err(e) => {\n        error!(error = %e, \"SyncMessage failed to serialize, this is a code bug\");\n        return Err(e.into());\n    }\n    Ok(bytes) => bytes,\n}","preventionTips":["Round-trip every SyncMessage variant in a unit test","Keep SyncMessage fields to JSON-native types (strings, numbers, Vec, String-keyed maps)","Gate protocol shape changes behind a version handshake"],"tags":["serde","serialization","sync","invariant"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}