{"record":{"id":"a17952cc7264ec97","repo":"zed-industries/zed","slug":"snowflake-sql-api-partition-returned-empty-resp","errorCode":null,"errorMessage":"snowflake sql api partition {} returned empty response body (http {})","messagePattern":"snowflake sql api partition (.+?) returned empty response body \\(http (.+?)\\)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/pull_examples.rs","lineNumber":426,"sourceCode":"        decoder\n            .read_to_end(&mut decompressed)\n            .context(\"failed to decompress gzip response\")?;\n        decompressed\n    } else {\n        body_bytes\n    };\n\n    if !status.is_success() && status.as_u16() != 202 {\n        let body_text = String::from_utf8_lossy(&body_bytes);\n        anyhow::bail!(\n            \"snowflake sql api partition request http {}: {}\",\n            status.as_u16(),\n            body_text\n        );\n    }\n\n    if body_bytes.is_empty() {\n        anyhow::bail!(\n            \"snowflake sql api partition {} returned empty response body (http {})\",\n            partition,\n            status.as_u16()\n        );\n    }\n\n    serde_json::from_slice::<SnowflakeStatementResponse>(&body_bytes).with_context(|| {\n        let body_preview = String::from_utf8_lossy(&body_bytes[..body_bytes.len().min(500)]);\n        format!(\n            \"failed to parse Snowflake SQL API partition {} response JSON (http {}): {}\",\n            partition,\n            status.as_u16(),\n            body_preview\n        )\n    })\n}\n\nasync fn fetch_partition_with_retries(","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/pull_examples.rs#L408-L444","documentation":"Raised in the Snowflake partition fetch when the response body is empty. Status was already accepted (2xx or 202), so this is not an HTTP error: 202 with an empty body is the SQL API's 'statement still executing, no rows for this partition yet' state, and an empty 200 is abnormal. Because the code cannot distinguish 'not ready' from 'broken', it bails instead of returning an empty iterator that would silently drop a partition's rows.","triggerScenarios":"Polling a partition of a long-running async statement: Snowflake answers 202 with zero-length body while the partition is still being produced. Also possible on gateway hiccups that close the stream early with a 200.","commonSituations":"Impatient polling intervals on multi-minute Snowflake queries; statements near the statement-timeout limit where some partitions land and others come back empty-202.","solutions":["Retry the pull after a short delay — an empty-202 partition usually fills once the statement finishes","If it persists, check the statement status in Snowflake (QUERY_HISTORY / the statement handle) to see whether it was aborted or failed","Reduce the query's scope or increase the statement timeout so partitions complete before polling"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// empty-202 means the statement is still executing: poll, don't fail\nlet mut backoff = 5;\nloop {\n    match fetch_partition(partition).await {\n        Ok(body) => break body,\n        Err(e) if e.to_string().contains(\"empty response body\") && backoff <= 80 => {\n            tokio::time::sleep(Duration::from_secs(backoff)).await;\n            backoff *= 2;\n        }\n        Err(e) => return Err(e),\n    }\n}","preventionTips":["Expect empty-202 bodies while an async Snowflake statement is still running; poll with exponential backoff","Never interpret an empty partition body as 'no rows' — this bail exists to prevent silent data loss","Check QUERY_HISTORY if a partition stays empty across several polls; the statement may have been aborted"],"tags":["rust","snowflake","sql-api","empty-response","edit-prediction"],"backgroundTag":"empty-response-body","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}