{"record":{"id":"3174f4f65fe16c80","repo":"zed-industries/zed","slug":"snowflake-sql-api-http","errorCode":null,"errorMessage":"snowflake sql api http {}: {}","messagePattern":"snowflake sql api http (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/pull_examples.rs","lineNumber":541,"sourceCode":"\n    let status = response.status();\n    let body_bytes = {\n        use futures::AsyncReadExt as _;\n\n        let mut body = response.into_body();\n        let mut bytes = Vec::new();\n        body.read_to_end(&mut bytes)\n            .await\n            .context(\"failed to read Snowflake SQL API response body\")?;\n        bytes\n    };\n\n    let snowflake_response = serde_json::from_slice::<SnowflakeStatementResponse>(&body_bytes)\n        .context(\"failed to parse Snowflake SQL API response JSON\")?;\n\n    if !status.is_success() && status.as_u16() != 202 && !is_timeout_response(&snowflake_response) {\n        let body_text = String::from_utf8_lossy(&body_bytes);\n        anyhow::bail!(\"snowflake sql api http {}: {}\", status.as_u16(), body_text);\n    }\n\n    if is_timeout_response(&snowflake_response) {\n        anyhow::bail!(\n            \"snowflake sql api timed out code={} message={}\",\n            snowflake_response.code.as_deref().unwrap_or(\"<no code>\"),\n            snowflake_response\n                .message\n                .as_deref()\n                .unwrap_or(\"<no message>\")\n        );\n    }\n\n    Ok(snowflake_response)\n}\n\npub async fn fetch_rejected_examples_after(\n    http_client: Arc<dyn HttpClient>,","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/pull_examples.rs#L523-L559","documentation":"Generic non-2xx failure from the Snowflake SQL API request path (pull_examples.rs): unlike the partition variant (error 231), this one first parses the body into SnowflakeStatementResponse and exempts timeout-shaped responses (code 000630 with 'timeout' in the message — handled as error 234) as well as 202. Any other failing status bails here with the status code and body text, which for Snowflake typically contains a JSON envelope with 'code' and 'message' describing the exact server-side error.","triggerScenarios":"Submitting/executing the examples query: 400 for malformed SQL or invalid request parameters, 401 when the auth token expired, 403 for missing role/warehouse privileges, 404 for an unknown statement handle, 429/5xx under load. The message is the catch-all for everything that is not 'accepted' and not a timeout.","commonSituations":"Token expiry during multi-hour pulls; role changes removing USAGE on the warehouse; Snowflake regional incidents; SQL referencing a table renamed after a schema migration.","solutions":["Read the embedded Snowflake code/message in {body} — it names the real cause (e.g. does not exist or not authorized)","Re-authenticate/refresh credentials and confirm the role has privileges on the warehouse, database, and schema","For 429/5xx, retry with backoff; for 400, fix the SQL or request payload"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match execute_statement(&client, request).await {\n    Err(e) if is_transient_snowflake_http(&e) => {\n        tokio::time::sleep(Duration::from_secs(30)).await;\n        execute_statement(&client, request).await?\n    }\n    Err(e) => {\n        // body embeds Snowflake's code/message envelope; surface it for diagnosis\n        anyhow::bail!(\"Snowflake SQL API failure: {e:#}\")\n    }\n    ok => ok?,\n}","preventionTips":["The body text names the real Snowflake error — always read it before retrying","Distinguish 4xx (fix credentials/SQL/privileges) from 5xx/429 (retry with backoff)","Timeout-shaped bodies are already classified separately (code 000630) — size the query to avoid them"],"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"}