spacedriveapp/spacedrive · error · anyhow::Error
Failed to deserialize sync response: {}
Error message
Failed to deserialize sync response: {} What it means
serde_json::from_slice::<SyncMessage> failed on the received response bytes: the payload is not valid JSON for the SyncMessage type. The dominant cause is version skew, where the peer encodes variants or fields this build does not know. Corrupted buffers are rare because read_exact enforces the announced length.
Source
Thrown at core/src/service/network/transports/sync.rs:308
.map_err(|e| anyhow::anyhow!("Failed to read response: {}", e))?;
Ok::<_, anyhow::Error>(resp_buf)
})
.await;
let resp_buf = match result {
Ok(Ok(buf)) => buf,
Ok(Err(e)) => return Err(e),
Err(_) => {
return Err(anyhow::anyhow!(
"Sync request timed out after 60s - peer {} not responding",
target_device
))
}
};
// Deserialize response
let response: SyncMessage = serde_json::from_slice(&resp_buf)
.map_err(|e| anyhow::anyhow!("Failed to deserialize sync response: {}", e))?;
debug!(
device_uuid = %target_device,
response_type = ?std::mem::discriminant(&response),
"Received sync response"
);
Ok(response)
}
/// Get list of currently connected sync partner devices FOR THIS LIBRARY
///
/// Returns device UUIDs that are:
/// 1. Members of this specific library (in devices table)
/// 2. Have sync_enabled=true in this library
/// 3. Currently network-connected (according to Iroh)
async fn get_connected_sync_partners(
&self,View on GitHub (pinned to 6dfeccf211)
Solutions
- Update both devices to the same core version and re-test the sync exchange
- Log the first bytes of resp_buf before failing, to see what the peer actually sent
- Add a protocol version to the sync ALPN or a message header so mismatched peers fail fast with a clear version error instead of a serde error
Defensive patterns
Strategy: try-catch
Validate before calling
// Verify both peers report the same protocol/core version before syncing assert_eq!(local_version, peer_version, "sync protocol mismatch");
Try / catch
match serde_json::from_slice::<SyncMessage>(&resp_buf) {
Err(e) => {
warn!(error = %e, head = ?&resp_buf[..resp_buf.len().min(64)], "unparseable sync response, likely version skew");
return Err(e.into());
}
Ok(msg) => msg,
} Prevention
- Update paired devices together so both run the same core version
- Version the sync protocol in the ALPN or a header and reject mismatches up front
- Log the first bytes of an unparseable response to identify what the peer sent
When it happens
Trigger: Peers running different core versions exchange sync messages with enum drift; the peer replied with a plain-text error string instead of a JSON frame; a peer truncation bug produced invalid bytes that still matched the announced length.
Common situations: Updating one device of a pair but not the other; development builds talking to release builds; a peer database imported from a newer schema.
Related errors
- Failed to deserialize sync response: {}
- Invalid event type: {}
- Invalid category: {}
- Invalid severity: {}
- Failed to serialize sync request: {}
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/96ed7f478f8fb178.
Report an issue: GitHub.