{"record":{"id":"61a1bcbe6d1d83bd","repo":"tursodatabase/turso","slug":"failed-to-parse-server-pages-selector","errorCode":null,"errorMessage":"Failed to parse server_pages_selector: {}","messagePattern":"Failed to parse server_pages_selector: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"cli/sync_server.rs","lineNumber":645,"sourceCode":"        } else {\n            req.server_revision.parse().unwrap_or(wal_state.max_frame)\n        };\n\n        let client_revision: u64 = if req.client_revision.is_empty() {\n            0\n        } else {\n            req.client_revision.parse().unwrap_or(0)\n        };\n\n        debug!(\n            \"Using server_revision={}, client_revision={}\",\n            server_revision, client_revision\n        );\n\n        let pages_selector: Option<RoaringBitmap> = if !req.server_pages_selector.is_empty() {\n            Some(\n                RoaringBitmap::deserialize_from(&req.server_pages_selector[..])\n                    .map_err(|e| anyhow!(\"Failed to parse server_pages_selector: {}\", e))?,\n            )\n        } else {\n            None\n        };\n\n        let mut seen_pages: HashSet<u32> = HashSet::new();\n        let mut pages_to_send: Vec<(u32, Vec<u8>)> = Vec::new();\n\n        let frame_size = WAL_FRAME_HEADER_SIZE + PAGE_SIZE;\n        let mut frame_buffer = vec![0u8; frame_size];\n\n        debug!(\n            \"pull-updates: scanning WAL frames {}..={} (client_revision={}, server_revision={})\",\n            client_revision + 1,\n            server_revision,\n            client_revision,\n            server_revision\n        );","sourceCodeStart":627,"sourceCodeEnd":663,"githubUrl":"https://github.com/tursodatabase/turso/blob/492c4a71cd7c2649e7df83da1471b74f4b1c7aa9/cli/sync_server.rs#L627-L663","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nreq.server_pages_selector = b\"1,5,9\".to_vec();\n\n// after\nlet mut buf = Vec::new();\nbitmap.serialize_into(&mut buf)?;\nreq.server_pages_selector = buf;","handlingStrategy":"fallback","validationCode":"// round-trip check before sending: if we can't read it, the server can't either\nroaring::RoaringBitmap::deserialize_from::<&[u8]>(&selector_bytes)\n    .map_err(|e| format!(\"selector bytes are not a valid RoaringBitmap: {e}\"))?;","typeGuard":null,"tryCatchPattern":"match pull_with_selector(&bitmap_bytes).await {\n    Ok(resp) => resp,\n    Err(e) if e.to_string().contains(\"server_pages_selector\") => {\n        pull_with_selector(&[]).await? // empty selector = request all pages\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["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"],"tags":["sync-server","roaring-bitmap","pages-selector","deserialization"],"backgroundTag":"roaring-bitmap-deserialize-failed","analyzedSha":"492c4a71cd7c2649e7df83da1471b74f4b1c7aa9","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}