{"record":{"id":"acf4f5c2e781794a","repo":"zed-industries/zed","slug":"snowflake-sql-api-returned-error-code-code-messa","errorCode":null,"errorMessage":"snowflake sql api returned error code={code} message={}","messagePattern":"snowflake sql api returned error code=(.+?) message=(.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/pull_examples.rs","lineNumber":1098,"sourceCode":"                \"zed_version\",\n            ],\n            rated_examples_from_response,\n        )\n        .await?;\n\n        all_examples.extend(examples);\n    }\n\n    Ok(all_examples)\n}\n\nfn rated_examples_from_response<'a>(\n    response: &'a SnowflakeStatementResponse,\n    column_indices: &'a std::collections::HashMap<String, usize>,\n) -> Result<Box<dyn Iterator<Item = Example> + 'a>> {\n    if let Some(code) = &response.code {\n        if code != SNOWFLAKE_SUCCESS_CODE {\n            anyhow::bail!(\n                \"snowflake sql api returned error code={code} message={}\",\n                response.message.as_deref().unwrap_or(\"<no message>\")\n            );\n        }\n    }\n\n    let iter = response\n        .data\n        .iter()\n        .enumerate()\n        .filter_map(move |(row_index, data_row)| {\n            let get_string = |name: &str| -> Option<String> {\n                let index = column_indices.get(name).copied()?;\n                match data_row.get(index)? {\n                    JsonValue::String(s) => Some(s.clone()),\n                    JsonValue::Null => None,\n                    other => Some(other.to_string()),\n                }","sourceCodeStart":1080,"sourceCodeEnd":1116,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/pull_examples.rs#L1080-L1116","documentation":"Raised by rated_examples_from_response (pull_examples.rs) when converting a Snowflake SQL API response into rated examples: the response carries a status code and it is not the success code '090001' (SNOWFLAKE_SUCCESS_CODE, statement succeeded with results). Snowflake puts its error taxonomy in this envelope (e.g. 000630 timeout, 090149 request limit), so the row iterator is never built and the error code plus message — or '<no message>' — are surfaced verbatim.","triggerScenarios":"Pulling rated examples where the statement completed with an application-level error: query error surfaces as a non-090001 code in the parsed response even though HTTP transport succeeded; also seen when a timeout-classified body slips through a path that does not pre-filter 000630.","commonSituations":"Schema drift (renamed/dropped columns in the examples table) making the rated-examples query fail server-side; concurrent statement limit hit; role lacking SELECT on the rated view.","solutions":["Match the embedded code against Snowflake's SQL API error list: 00060x/000630 -> query execution issues or timeout, 090xxx -> API request issues (e.g. 090149 = exceeded concurrent statement limit)","Fix the server-side cause: validate the query/columns in Snowsight, grant missing privileges, or shrink the query","Re-run the pull once the underlying statement succeeds; already-fetched examples are not lost"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"fn response_is_success(response: &SnowflakeStatementResponse) -> bool {\n    response.code.as_deref().map(|c| c == \"090001\").unwrap_or(true)\n}","typeGuard":null,"tryCatchPattern":"match rated_examples_from_response(&response, &column_indices) {\n    Err(e) if e.to_string().contains(\"code=000630\") => {\n        log::warn!(\"statement timed out; retrying rated pull with a smaller window\");\n        retry_with_smaller_window()?;\n    }\n    Err(e) => return Err(e.context(\"rated-examples pull failed\")),\n    Ok(examples) => extend_all_examples(examples),\n}","preventionTips":["Verify the rated-examples query returns envelope code 090001 in Snowsight before automating pulls","Map embedded codes to actions: 000630 timeout -> shrink query, 090149 -> reduce concurrency, 000xxx -> fix SQL/grants","Never treat this error as an empty result set — it means the statement failed server-side"],"tags":["rust","snowflake","sql-api","error-code","edit-prediction"],"backgroundTag":"backend-error-code","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"}