tursodatabase/turso · error
Failed to parse server_pages_selector
Error message
Failed to parse server_pages_selector: {} What it means
When the server_pages_selector field of a page pull request is non-empty, the server deserializes it as a RoaringBitmap to learn which pages the client wants. This error means those bytes are not a valid RoaringBitmap serialization in the format the server's roaring crate expects.
Solutions
- Serialize the selector with the same roaring crate and format version the server deserializes with
- If selective page sync is not needed, send an empty server_pages_selector so the server sends all applicable pages
- Round-trip the buffer locally (deserialize your own bytes) before sending to catch format mismatches early
Example fix
// before req.server_pages_selector = b"1,5,9".to_vec(); // after let mut buf = Vec::new(); bitmap.serialize_into(&mut buf)?; req.server_pages_selector = buf;
Defensive patterns
Strategy: fallback
Validate before calling
// round-trip check before sending: if we can't read it, the server can't either
roaring::RoaringBitmap::deserialize_from::<&[u8]>(&selector_bytes)
.map_err(|e| format!("selector bytes are not a valid RoaringBitmap: {e}"))?; Try / catch
match pull_with_selector(&bitmap_bytes).await {
Ok(resp) => resp,
Err(e) if e.to_string().contains("server_pages_selector") => {
pull_with_selector(&[]).await? // empty selector = request all pages
}
Err(e) => return Err(e),
} Prevention
- Serialize and deserialize the selector with the same roaring crate version on both ends
- Add a round-trip unit test over the wire bytes in CI
- When in doubt, omit the selector (empty bytes) to request all pages
When it happens
Trigger: Passing arbitrary bytes, a hex/base64 string, or a bitmap serialized by an incompatible roaring implementation (different crate version, portable vs native format) in server_pages_selector of a POST /pull-updates page request.
Common situations: Mixing roaring bitmap crate versions or serialization formats between client and server; sending the page list as a JSON array instead of serialized bitmap bytes; buffer corruption during transfer.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- buffer too short for u32 at offset
- buffer too short for u64 at offset
- database page is missing from replace-base snapshot
- database page number does not fit u32
- Empty pipeline response
AI-assisted analysis of tursodatabase/turso@492c4a71cd (2026-08-20).
Data as JSON: /api/errors/61a1bcbe6d1d83bd.
Report an issue: GitHub.
Appendix: source
Thrown at cli/sync_server.rs:645
} else {
req.server_revision.parse().unwrap_or(wal_state.max_frame)
};
let client_revision: u64 = if req.client_revision.is_empty() {
0
} else {
req.client_revision.parse().unwrap_or(0)
};
debug!(
"Using server_revision={}, client_revision={}",
server_revision, client_revision
);
let pages_selector: Option<RoaringBitmap> = if !req.server_pages_selector.is_empty() {
Some(
RoaringBitmap::deserialize_from(&req.server_pages_selector[..])
.map_err(|e| anyhow!("Failed to parse server_pages_selector: {}", e))?,
)
} else {
None
};
let mut seen_pages: HashSet<u32> = HashSet::new();
let mut pages_to_send: Vec<(u32, Vec<u8>)> = Vec::new();
let frame_size = WAL_FRAME_HEADER_SIZE + PAGE_SIZE;
let mut frame_buffer = vec![0u8; frame_size];
debug!(
"pull-updates: scanning WAL frames {}..={} (client_revision={}, server_revision={})",
client_revision + 1,
server_revision,
client_revision,
server_revision
);View on GitHub (pinned to 492c4a71cd)