{"record":{"id":"9bcbcf1d72356fd4","repo":"tursodatabase/turso","slug":"invalid-response-shape","errorCode":null,"errorMessage":"invalid response shape","messagePattern":"invalid response shape","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"bindings/rust/src/sync.rs","lineNumber":1305,"sourceCode":"                    \"requests\": [{\n                        \"type\": \"execute\",\n                        \"stmt\": { \"sql\": sql }\n                    }]\n                }))\n                .send()\n                .await?\n                .error_for_status()?;\n\n            let value: serde_json::Value = resp.json().await?;\n\n            let result = &value[\"results\"][0];\n            if result[\"type\"] != \"ok\" {\n                return Err(anyhow!(\"remote sql execution failed: {value}\"));\n            }\n\n            let rows = result[\"response\"][\"result\"][\"rows\"]\n                .as_array()\n                .ok_or_else(|| anyhow!(\"invalid response shape\"))?;\n\n            Ok(rows\n                .iter()\n                .map(|row| {\n                    row.as_array()\n                        .unwrap()\n                        .iter()\n                        .map(|cell| match cell[\"value\"].clone() {\n                            serde_json::Value::Null => Value::Null,\n                            serde_json::Value::Number(number) => {\n                                if number.is_i64() {\n                                    Value::Integer(number.as_i64().unwrap())\n                                } else {\n                                    Value::Real(number.as_f64().unwrap())\n                                }\n                            }\n                            serde_json::Value::String(s) => Value::Text(s),\n                            _ => panic!(\"unexpected json output\"),","sourceCodeStart":1287,"sourceCodeEnd":1323,"githubUrl":"https://github.com/tursodatabase/turso/blob/492c4a71cd7c2649e7df83da1471b74f4b1c7aa9/bindings/rust/src/sync.rs#L1287-L1323","documentation":"Thrown by TursoServer::db_sql when results[0] is ok but the element at response.result.rows is missing or not a JSON array (bindings/rust/src/sync.rs:1208). The server answered successfully, but the response does not match the shape the harness expects for a row set.","triggerScenarios":"Server version that returns a different response schema (renamed fields, rows nested elsewhere); a statement type that legitimately returns no rows object; response format changed on one side of a client/server version skew.","commonSituations":"Harness and server built from different commits during a bisect; the Hrana/sync response format evolved in core without updating the bindings test harness; a new statement kind added server-side.","solutions":["Print the full response value before the shape check to see what the server actually returned","Rebuild both the sync server binary and the bindings crate from the same commit","Run the tests from a single workspace checkout so client and server versions match","If the statement is non-query, use an execution helper that does not expect rows"],"exampleFix":"// before\nlet rows = result[\"response\"][\"result\"][\"rows\"]\n    .as_array()\n    .ok_or_else(|| anyhow!(\"invalid response shape\"))?;\n// after\nlet Some(rows) = result[\"response\"][\"result\"][\"rows\"].as_array() else {\n    anyhow::bail!(\"unexpected response: {value}\");\n};","handlingStrategy":"type-guard","validationCode":"let value: serde_json::Value = resp.json().await?;\nanyhow::ensure!(has_row_array(&value), \"unexpected sync response: {value}\");","typeGuard":"fn has_row_array(v: &serde_json::Value) -> bool {\n    v[\"results\"][0][\"response\"][\"result\"][\"rows\"].is_array()\n}","tryCatchPattern":null,"preventionTips":["Validate the response shape before indexing into it","Pin harness and server to the same commit in CI","Print the raw response when the shape check fails so drift is obvious"],"tags":["sync","test-harness","json","response-shape","rust"],"backgroundTag":"schema-validation-failed","analyzedSha":"492c4a71cd7c2649e7df83da1471b74f4b1c7aa9","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}