spacedriveapp/spacedrive · error · anyhow::Error

Unexpected response to pull request

Error message

Unexpected response to pull request

What it means

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.

Source

Thrown at core/src/ops/files/copy/strategy.rs:571

				file_metadata: Some(metadata),
				..
			} => {
				ctx.log(format!(
					"PullRequest accepted: {} bytes",
					metadata.size
				));
				metadata
			}
			crate::service::network::protocol::file_transfer::FileTransferMessage::PullResponse {
				accepted: false,
				error,
				..
			} => {
				let err_msg = error.unwrap_or_else(|| "Unknown error".to_string());
				return Err(anyhow::anyhow!("Pull request rejected: {}", err_msg));
			}
			_ => {
				return Err(anyhow::anyhow!(
					"Unexpected response to pull request"
				));
			}
		};

		let file_size = file_metadata.size;

		// Ensure parent directory exists
		if let Some(parent) = local_dest_path.parent() {
			fs::create_dir_all(parent).await?;
		}

		// Determine final file path
		let final_dest_path =
			if local_dest_path.is_dir() || local_dest_path.to_string_lossy().ends_with('/') {
				// Destination is a directory - append source filename
				let dir_path = local_dest_path.to_path_buf();
				fs::create_dir_all(&dir_path).await?;

View on GitHub (pinned to 6dfeccf211)

Solutions

  1. Ensure both devices run the same core/daemon version, then retry
  2. Log the raw first message (msg_type byte and length) to identify what arrived instead
  3. Re-pair the devices after an upgrade so protocol state is consistent
  4. If it persists on identical versions, capture logs from both sides and report a protocol bug
Defensive patterns

Strategy: try-catch

Try / catch

match remote_strategy.execute_pull(ctx, &src, &dst).await {
    Ok(n) => Ok(n),
    Err(e) if e.to_string().contains("Unexpected response to pull request") => {
        // almost always a version mismatch: block retries until versions align
        mark_peer_incompatible(peer_id);
        Err(anyhow::anyhow!("protocol desync with peer; align daemon versions and retry: {}", e))
    }
    Err(e) => Err(e),
}

Prevention

When it happens

Trigger: 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.

Common situations: Only one device of a pair upgraded; experimental builds with changed FileTransferMessage ordering; protocol refactor deployed inconsistently.

Related errors


AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16). Data as JSON: /api/errors/45655a23c9140f2e. Report an issue: GitHub.