{"record":{"id":"db4fa3d4c1652ba6","repo":"spacedriveapp/spacedrive","slug":"unexpected-response-type","errorCode":null,"errorMessage":"Unexpected response type: {}","messagePattern":"Unexpected response type: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"core/src/ops/files/copy/strategy.rs","lineNumber":1286,"sourceCode":"\t\t.await?;\n\tsend_stream.write_all(&completion_data).await?;\n\tsend_stream.flush().await?;\n\n\tctx.log(format!(\n\t\t\"Completion message sent, waiting for final acknowledgment from receiver\"\n\t));\n\n\tsend_stream\n\t\t.finish()\n\t\t.map_err(|e| anyhow::anyhow!(\"Failed to finish stream: {}\", e))?;\n\n\tctx.log(\"Waiting for TransferFinalAck from receiver...\".to_string());\n\n\tlet mut msg_type = [0u8; 1];\n\trecv_stream.read_exact(&mut msg_type).await?;\n\n\tif msg_type[0] != 0 {\n\t\treturn Err(anyhow::anyhow!(\"Unexpected response type: {}\", msg_type[0]));\n\t}\n\n\tlet mut len_buf = [0u8; 4];\n\trecv_stream.read_exact(&mut len_buf).await?;\n\tlet msg_len = u32::from_be_bytes(len_buf) as usize;\n\n\tlet mut msg_buf = vec![0u8; msg_len];\n\trecv_stream.read_exact(&mut msg_buf).await?;\n\n\tlet ack_message: crate::service::network::protocol::file_transfer::FileTransferMessage =\n\t\trmp_serde::from_slice(&msg_buf)?;\n\n\tmatch ack_message {\n\t\tcrate::service::network::protocol::file_transfer::FileTransferMessage::TransferFinalAck { transfer_id: ack_id } => {\n\t\t\tif ack_id != transfer_id {\n\t\t\t\treturn Err(anyhow::anyhow!(\"Received ack for wrong transfer: expected {}, got {}\", transfer_id, ack_id));\n\t\t\t}\n\t\t\tctx.log(\"Received TransferFinalAck from receiver - transfer confirmed!\".to_string());","sourceCodeStart":1268,"sourceCodeEnd":1304,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/core/src/ops/files/copy/strategy.rs#L1268-L1304","documentation":"Reading the final acknowledgment expects a framing byte of 0 (the marker for rmp-serialized messages) followed by a length, but the first byte read was non-zero. The bytes on the receive stream do not follow the expected framing - typically version skew between the two daemons, or a misaligned or corrupted stream. The offending byte value is included in the error.","triggerScenarios":"Peer running a different protocol version whose framing differs; the receive stream left misaligned by an earlier partial read; peer sent an unrecognized frame type.","commonSituations":"One device upgraded sd-core while the other stayed on an old version; mixed-version LANs; downgrade and upgrade cycles leaving incompatible peers paired.","solutions":["Confirm both devices run the same sd-core version and upgrade the outlier","Retry once on a fresh connection to rule out stream misalignment","Note the reported byte value - a consistent non-zero value identifies the peer's frame type and confirms version skew","Re-pair devices after upgrading if the errors persist"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match recv_stream.read_exact(&mut msg_type).await {\n    Ok(_) if msg_type[0] == 0 => { /* expected framing */ }\n    Ok(_) => {\n        // Protocol mismatch: do not retry on this connection; require matching versions.\n        anyhow::bail!(\"Protocol framing mismatch (byte {}) - align device versions\", msg_type[0]);\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Upgrade paired devices together","Pin protocol versions in pairing metadata","Test cross-version transfers after upgrades"],"tags":["network","protocol","versioning","file-transfer"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}