zed-industries/zed · error

snowflake sql api returned error code={code} message={}

Error message

snowflake sql api returned error code={code} message={}

What it means

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.

Source

Thrown at crates/edit_prediction_cli/src/pull_examples.rs:1098

                "zed_version",
            ],
            rated_examples_from_response,
        )
        .await?;

        all_examples.extend(examples);
    }

    Ok(all_examples)
}

fn rated_examples_from_response<'a>(
    response: &'a SnowflakeStatementResponse,
    column_indices: &'a std::collections::HashMap<String, usize>,
) -> Result<Box<dyn Iterator<Item = Example> + 'a>> {
    if let Some(code) = &response.code {
        if code != SNOWFLAKE_SUCCESS_CODE {
            anyhow::bail!(
                "snowflake sql api returned error code={code} message={}",
                response.message.as_deref().unwrap_or("<no message>")
            );
        }
    }

    let iter = response
        .data
        .iter()
        .enumerate()
        .filter_map(move |(row_index, data_row)| {
            let get_string = |name: &str| -> Option<String> {
                let index = column_indices.get(name).copied()?;
                match data_row.get(index)? {
                    JsonValue::String(s) => Some(s.clone()),
                    JsonValue::Null => None,
                    other => Some(other.to_string()),
                }

View on GitHub (pinned to f4178619ac)

Solutions

  1. 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)
  2. Fix the server-side cause: validate the query/columns in Snowsight, grant missing privileges, or shrink the query
  3. Re-run the pull once the underlying statement succeeds; already-fetched examples are not lost
Defensive patterns

Strategy: try-catch

Validate before calling

fn response_is_success(response: &SnowflakeStatementResponse) -> bool {
    response.code.as_deref().map(|c| c == "090001").unwrap_or(true)
}

Try / catch

match rated_examples_from_response(&response, &column_indices) {
    Err(e) if e.to_string().contains("code=000630") => {
        log::warn!("statement timed out; retrying rated pull with a smaller window");
        retry_with_smaller_window()?;
    }
    Err(e) => return Err(e.context("rated-examples pull failed")),
    Ok(examples) => extend_all_examples(examples),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/acf4f5c2e781794a. Report an issue: GitHub.