{"record":{"id":"5c504a0fcc201d97","repo":"zed-industries/zed","slug":"snowflake-sql-api-timed-out-code-message","errorCode":null,"errorMessage":"snowflake sql api timed out code={} message={}","messagePattern":"snowflake sql api timed out code=(.+?) message=(.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/pull_examples.rs","lineNumber":545,"sourceCode":"\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>,\n    after_timestamps: &[(bool, String)],\n    max_rows_per_timestamp: Option<usize>,\n    offset: usize,\n    background_executor: BackgroundExecutor,","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/pull_examples.rs#L527-L563","documentation":"Raised when the Snowflake SQL API response is a timeout: is_timeout_response (pull_examples.rs:2063) matches a body whose code is '000630' AND whose message contains 'timeout' (case-insensitive). This is Snowflake reporting that the statement exceeded its execution timeout (STATEMENT_TIMEOUT_IN_SECONDS) or the request-level timeout — the statement is still 'executing' from the API's view, so no rows are returned. The crate keeps a companion helper is_snowflake_timeout_error for classifying these in downstream retry logic, signalling they are expected and often retryable.","triggerScenarios":"Running a pull-examples query (rated/requested/settled/captured/rejected) over a large time window so the statement runs longer than the configured timeout; the HTTP call succeeds but the parsed response body carries code=000630 with a timeout message instead of data.","commonSituations":"Growing datasets making previously-fine queries exceed STATEMENT_TIMEOUT_IN_SECONDS; warehouse size downgraded so the same query takes longer; ad-hoc wide date-range pulls.","solutions":["Reduce the query scope (shorter time window / fewer examples per run) so the statement finishes within the timeout","Raise the timeout, e.g. ALTER SESSION SET STATEMENT_TIMEOUT_IN_SECONDS = 3600, or use a larger warehouse for the pull","Re-run: the code classifies timeout errors as retryable (is_snowflake_timeout_error), and pulls resume from what was already fetched"],"exampleFix":"-- before\nSELECT ... FROM examples WHERE ts > '2026-01-01'; -- huge range, times out (000630)\n\n-- after\nALTER SESSION SET STATEMENT_TIMEOUT_IN_SECONDS = 7200;\nSELECT ... FROM examples WHERE ts BETWEEN '2026-07-01' AND '2026-07-15';","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match fetch_examples(&state).await {\n    Err(e) if is_snowflake_timeout_error(&e) => {\n        // statement hit its execution timeout; shrink the window and retry\n        state.shrink_time_window();\n        fetch_examples(&state).await?\n    }\n    other => other?,\n}","preventionTips":["Size pulls to finish under STATEMENT_TIMEOUT_IN_SECONDS, or raise the timeout for known-large queries","Reuse the crate's is_snowflake_timeout_error classifier to route 000630 timeouts into retry logic","Prefer smaller time-windowed pulls over one giant statement; they resume cleanly on retry"],"tags":["rust","snowflake","timeout","sql-api","edit-prediction"],"backgroundTag":"query-timeout","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}