{"record":{"id":"aec829ea989e00b9","repo":"zed-industries/zed","slug":"snowflake-sql-api-partition-request-http","errorCode":null,"errorMessage":"snowflake sql api partition request http {}: {}","messagePattern":"snowflake sql api partition request http (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/pull_examples.rs","lineNumber":418,"sourceCode":"            .await\n            .context(\"failed to read Snowflake SQL API partition response body\")?;\n        bytes\n    };\n\n    let body_bytes = if content_encoding.as_deref() == Some(\"gzip\") {\n        let mut decoder = GzDecoder::new(&body_bytes[..]);\n        let mut decompressed = Vec::new();\n        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 {}): {}\",","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/pull_examples.rs#L400-L436","documentation":"Raised while fetching one partition of a Snowflake SQL API result (pull_examples.rs): after the async request completes, a status that is neither 2xx nor 202 (Accepted, the SQL API's 'statement still executing' signal) is fatal. The body is decompressed from gzip first when the content-encoding says so, then the raw status code and lossy-UTF-8 body text are embedded in the error so the Snowflake error envelope (code/message) is visible.","triggerScenarios":"Partitioned fetch of a large result set where one partition request returns 400 (bad request/malformed partition handle), 401/403 (expired token or missing privileges on the warehouse/database), or 5xx. Distinct from the sibling 'timed out' error: a timeout-shaped response body with code 000630 is classified separately at the outer request level.","commonSituations":"Long ETL-style example pulls where the OAuth/session token expires mid-pagination; Snowflake incidents returning 503; partition handles invalidated by the statement being aborted.","solutions":["Check the embedded status/body: 401/403 -> refresh Snowflake credentials and re-run; 400 -> the partition handle or statement may be stale, re-issue the query","Re-run the pull: the flow is resumable per example/partition, so transient 5xx/503 usually clear on retry","For very large pulls, reduce partition size or query scope so individual partition requests finish quickly"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match fetch_partition(partition).await {\n    Err(e) if is_transient_snowflake_http(&e) => {\n        tokio::time::sleep(Duration::from_secs(30)).await;\n        fetch_partition(partition).await?\n    }\n    Err(e) if e.to_string().contains(\"http 40\") => {\n        anyhow::bail!(\"credentials/partition handle problem, refresh auth: {e:#}\")\n    }\n    other => other?,\n}","preventionTips":["Refresh Snowflake tokens before starting large multi-partition pulls","Treat embedded 401/403 as credential problems and 5xx as transient — only the latter is worth retrying","Keep partition sizes modest so a single retried partition is cheap"],"tags":["rust","snowflake","http","sql-api","edit-prediction"],"backgroundTag":"api-error-response","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"}