{"record":{"id":"f361e637be8ea6ef","repo":"tursodatabase/turso","slug":"failed-to-decode-pullupdatesrequest","errorCode":null,"errorMessage":"Failed to decode PullUpdatesRequest: {}","messagePattern":"Failed to decode PullUpdatesRequest: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/sync_server.rs","lineNumber":591,"sourceCode":"            })\n        } else {\n            stmt.run_ignore_rows()?;\n            Ok(StmtResult {\n                cols: vec![],\n                rows: vec![],\n                affected_row_count: 0,\n                last_insert_rowid: None,\n                replication_index: None,\n                rows_read: 0,\n                rows_written: 0,\n                query_duration_ms: 0.0,\n            })\n        }\n    }\n\n    fn handle_pull_updates(&self, db: &DbHandle, body: &[u8]) -> Result<HttpResponse> {\n        let req = <PullUpdatesReqProtoBody as Message>::decode(body)\n            .map_err(|e| anyhow!(\"Failed to decode PullUpdatesRequest: {}\", e))?;\n\n        debug!(\n            \"Pull updates request: server_revision={}, client_revision={}\",\n            req.server_revision, req.client_revision\n        );\n\n        let encoding =\n            PageUpdatesEncodingReq::try_from(req.encoding).unwrap_or(PageUpdatesEncodingReq::Raw);\n\n        if encoding == PageUpdatesEncodingReq::Zstd {\n            return Err(anyhow!(\"Zstd encoding is not supported\"));\n        }\n\n        if PullUpdatesStreamKind::try_from(req.stream_kind).unwrap_or(PullUpdatesStreamKind::Pages)\n            == PullUpdatesStreamKind::MvccLogicalLog\n        {\n            return self.handle_logical_pull_updates(db, &req);\n        }","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/tursodatabase/turso/blob/492c4a71cd7c2649e7df83da1471b74f4b1c7aa9/cli/sync_server.rs#L573-L609","documentation":"The POST /pull-updates endpoint decodes the request body as a protobuf PullUpdatesRequest using prost. This error means the bytes are not a decodable PullUpdatesRequest: wrong message type, truncated or corrupted wire data, or a schema (field number/type) mismatch between the client's generated code and the server's.","triggerScenarios":"POSTing JSON, arbitrary bytes, or a different protobuf message to /pull-updates; a client built against different .proto revisions; a proxy truncating the body so the varint/payload lengths no longer parse.","commonSituations":"Version skew between the turso sync client and this test server; manually crafted protobuf in tests; middleware that compresses or rewrites request bodies; mixing up the JSON pipeline route and the protobuf pull route.","solutions":["Encode the request with prost (or code generated from the same protos) at the same commit as the server","Verify the sent body length matches Content-Length and was not truncated in transit","Confirm you are hitting POST /pull-updates with protobuf, not /v2/pipeline with JSON","Regenerate the client protobuf types after updating the sync proto files"],"exampleFix":"// before: hand-rolled bytes\nlet body = b\"{\\\"server_revision\\\": 5}\".to_vec();\n\n// after: prost-encoded request\nlet req = PullUpdatesReqProtoBody { server_revision, client_revision, ..Default::default() };\nlet body = req.encode_to_vec();","handlingStrategy":"validation","validationCode":"// client side: always encode with prost-generated types, then sanity-check length\nlet body = PullUpdatesReqProtoBody { server_revision, client_revision, ..Default::default() }.encode_to_vec();\nassert!(!body.is_empty(), \"encoded PullUpdatesRequest must not be empty\");","typeGuard":null,"tryCatchPattern":"// server/operator side: decode failures mean bad input, answer 400 not 500\nmatch <PullUpdatesReqProtoBody as Message>::decode(&body[..]) {\n    Ok(req) => handle(req),\n    Err(_) => HttpResponse { status: 400, .. },\n}","preventionTips":["Pin client and server to the same proto revision","Never send JSON or hand-packed bytes to /pull-updates","Log body length on decode failure to spot proxy truncation"],"tags":["sync-server","protobuf","prost","pull-updates","decode"],"backgroundTag":"protobuf-decode-failed","analyzedSha":"492c4a71cd7c2649e7df83da1471b74f4b1c7aa9","analyzedAt":"2026-09-13T18:13:59.796Z","contentChangedAt":"2026-09-13T18:13:59.796Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}