{"record":{"id":"45655a23c9140f2e","repo":"spacedriveapp/spacedrive","slug":"unexpected-response-to-pull-request","errorCode":null,"errorMessage":"Unexpected response to pull request","messagePattern":"Unexpected response to pull request","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"core/src/ops/files/copy/strategy.rs","lineNumber":571,"sourceCode":"\t\t\t\tfile_metadata: Some(metadata),\n\t\t\t\t..\n\t\t\t} => {\n\t\t\t\tctx.log(format!(\n\t\t\t\t\t\"PullRequest accepted: {} bytes\",\n\t\t\t\t\tmetadata.size\n\t\t\t\t));\n\t\t\t\tmetadata\n\t\t\t}\n\t\t\tcrate::service::network::protocol::file_transfer::FileTransferMessage::PullResponse {\n\t\t\t\taccepted: false,\n\t\t\t\terror,\n\t\t\t\t..\n\t\t\t} => {\n\t\t\t\tlet err_msg = error.unwrap_or_else(|| \"Unknown error\".to_string());\n\t\t\t\treturn Err(anyhow::anyhow!(\"Pull request rejected: {}\", err_msg));\n\t\t\t}\n\t\t\t_ => {\n\t\t\t\treturn Err(anyhow::anyhow!(\n\t\t\t\t\t\"Unexpected response to pull request\"\n\t\t\t\t));\n\t\t\t}\n\t\t};\n\n\t\tlet file_size = file_metadata.size;\n\n\t\t// Ensure parent directory exists\n\t\tif let Some(parent) = local_dest_path.parent() {\n\t\t\tfs::create_dir_all(parent).await?;\n\t\t}\n\n\t\t// Determine final file path\n\t\tlet final_dest_path =\n\t\t\tif local_dest_path.is_dir() || local_dest_path.to_string_lossy().ends_with('/') {\n\t\t\t\t// Destination is a directory - append source filename\n\t\t\t\tlet dir_path = local_dest_path.to_path_buf();\n\t\t\t\tfs::create_dir_all(&dir_path).await?;","sourceCodeStart":553,"sourceCodeEnd":589,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/core/src/ops/files/copy/strategy.rs#L553-L589","documentation":"The first message the peer sent back was not a PullResponse at all (strategy.rs:570-574). The connection and stream succeeded, but the dialogue is desynchronized — the remote speaks a different protocol version that frames the exchange differently, or it pushed an unexpected message (e.g. TransferError) where the response was expected.","triggerScenarios":"Mixed daemon versions where the remote's file-transfer protocol emits a different first message; a proxy or middle layer altering the byte stream; peer bug sending an error or handshake message instead of the PullResponse.","commonSituations":"Only one device of a pair upgraded; experimental builds with changed FileTransferMessage ordering; protocol refactor deployed inconsistently.","solutions":["Ensure both devices run the same core/daemon version, then retry","Log the raw first message (msg_type byte and length) to identify what arrived instead","Re-pair the devices after an upgrade so protocol state is consistent","If it persists on identical versions, capture logs from both sides and report a protocol bug"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match remote_strategy.execute_pull(ctx, &src, &dst).await {\n    Ok(n) => Ok(n),\n    Err(e) if e.to_string().contains(\"Unexpected response to pull request\") => {\n        // almost always a version mismatch: block retries until versions align\n        mark_peer_incompatible(peer_id);\n        Err(anyhow::anyhow!(\"protocol desync with peer; align daemon versions and retry: {}\", e))\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Upgrade both devices together so FileTransferMessage ordering stays compatible","Log the unexpected message type when this fires to identify the divergence","Version-handshake peers before starting file transfers"],"tags":["rust","spacedrive","pull","protocol-mismatch","version-skew","file-transfer"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}