tursodatabase/turso · error

Failed to decode PullUpdatesRequest

Error message

Failed to decode PullUpdatesRequest: {}

What it means

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.

Solutions

  1. Encode the request with prost (or code generated from the same protos) at the same commit as the server
  2. Verify the sent body length matches Content-Length and was not truncated in transit
  3. Confirm you are hitting POST /pull-updates with protobuf, not /v2/pipeline with JSON
  4. Regenerate the client protobuf types after updating the sync proto files

Example fix

// before: hand-rolled bytes
let body = b"{\"server_revision\": 5}".to_vec();

// after: prost-encoded request
let req = PullUpdatesReqProtoBody { server_revision, client_revision, ..Default::default() };
let body = req.encode_to_vec();
Defensive patterns

Strategy: validation

Validate before calling

// client side: always encode with prost-generated types, then sanity-check length
let body = PullUpdatesReqProtoBody { server_revision, client_revision, ..Default::default() }.encode_to_vec();
assert!(!body.is_empty(), "encoded PullUpdatesRequest must not be empty");

Try / catch

// server/operator side: decode failures mean bad input, answer 400 not 500
match <PullUpdatesReqProtoBody as Message>::decode(&body[..]) {
    Ok(req) => handle(req),
    Err(_) => HttpResponse { status: 400, .. },
}

Prevention

When it happens

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

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of tursodatabase/turso@492c4a71cd (2026-09-13). Data as JSON: /api/errors/f361e637be8ea6ef. Report an issue: GitHub.

Appendix: source

Thrown at cli/sync_server.rs:591

            })
        } else {
            stmt.run_ignore_rows()?;
            Ok(StmtResult {
                cols: vec![],
                rows: vec![],
                affected_row_count: 0,
                last_insert_rowid: None,
                replication_index: None,
                rows_read: 0,
                rows_written: 0,
                query_duration_ms: 0.0,
            })
        }
    }

    fn handle_pull_updates(&self, db: &DbHandle, body: &[u8]) -> Result<HttpResponse> {
        let req = <PullUpdatesReqProtoBody as Message>::decode(body)
            .map_err(|e| anyhow!("Failed to decode PullUpdatesRequest: {}", e))?;

        debug!(
            "Pull updates request: server_revision={}, client_revision={}",
            req.server_revision, req.client_revision
        );

        let encoding =
            PageUpdatesEncodingReq::try_from(req.encoding).unwrap_or(PageUpdatesEncodingReq::Raw);

        if encoding == PageUpdatesEncodingReq::Zstd {
            return Err(anyhow!("Zstd encoding is not supported"));
        }

        if PullUpdatesStreamKind::try_from(req.stream_kind).unwrap_or(PullUpdatesStreamKind::Pages)
            == PullUpdatesStreamKind::MvccLogicalLog
        {
            return self.handle_logical_pull_updates(db, &req);
        }

View on GitHub (pinned to 492c4a71cd)