cube-js/cube · error · ApiError

{method} {path} failed with {status}: {detail}

Error message

{method} {path} failed with {status}: {detail}

What it means

The ApiError tail of every cube-cli HTTP request (finish_response): the server responded with a non-success HTTP status. The placeholders carry the method, path, status code, and the response body detail. This is not a transport failure — the server was reached and deliberately rejected the request, so retrying unchanged will usually fail again.

Source

Thrown at rust/cube-cli/src/client.rs:409

        let (mut status, mut text) = send(build_form(), self.token()).await?;
        if status == StatusCode::UNAUTHORIZED && self.try_refresh().await? {
            let (s, t) = send(build_form(), self.token()).await?;
            status = s;
            text = t;
        }
        self.finish_response(&Method::POST, path, status, text)
    }

    /// Shared tail of every request: error mapping + JSON/HTML handling.
    fn finish_response(
        &self,
        method: &Method,
        path: &str,
        status: StatusCode,
        text: String,
    ) -> Result<Value> {
        if !status.is_success() {
            return Err(anyhow::Error::new(ApiError {
                status,
                method: method.clone(),
                path: path.to_string(),
                detail: failure_detail(&text),
            }));
        }

        if text.trim().is_empty() {
            return Ok(Value::Null);
        }
        // Cube Cloud serves the web app (200 + HTML) for unknown routes.
        // Surface that as "endpoint not available" instead of returning the
        // HTML as a JSON string, which downstream renders as an empty table.
        let trimmed = text.trim_start();
        let looks_like_html =
            trimmed.len() >= 2 && trimmed.starts_with('<') && !trimmed.starts_with("<?xml");
        if looks_like_html {
            api_bail!(

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Read the {detail} body — it usually names the concrete validation or auth problem
  2. Fix the request payload, path, or credentials based on the status code (401/403 auth, 400 validation, 404 wrong path)
  3. For persistent failures, capture the status and body and report them to the server operators
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at rust/cube-cli/src/client.rs:409 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/4b2cce546742dc4b. Report an issue: GitHub.