cube-js/cube · error

data model on {branch} has {} compilation error(s)

Error message

data model on {branch} has {} compilation error(s)

What it means

`cube validate` compares the branch's data model against the API's compiler and, when compilation errors are returned, bails with this message summarizing the error count. The detailed errors are printed just above (as a list, or JSON with --json); the bail message is the final verdict.

Source

Thrown at rust/cube-cli/src/commands/validate.rs:132

        for error in &errors {
            eprintln!("  {}", format_error(error));
        }
    }

    if !valid {
        // Non-zero exit is the point of the command in CI, so it holds in
        // --json mode too, where the report above was printed as JSON.
        //
        // With nothing to list there is no stderr header above it: the header
        // exists to introduce a list, and repeating the verdict on two lines
        // says less than the one line that also says what to look at.
        if errors.is_empty() {
            bail!(
                "data model on {branch} could not be validated \
                 (the API reported a failure without any compilation errors)"
            );
        }
        bail!(
            "data model on {branch} has {} compilation error(s)",
            errors.len()
        );
    }

    Ok(())
}

#[cfg(test)]
mod tests {
    use super::*;
    use serde_json::json;

    #[test]
    fn an_error_is_prefixed_with_the_file_only_when_the_compiler_named_one() {
        assert_eq!(
            format_error(&json!({"fileName": "model/cubes/orders.yml", "message": "no sql"})),
            "model/cubes/orders.yml: no sql"

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Read the compilation errors printed above the message and fix the listed data model files
  2. Re-run `cube validate` until it passes before deploying
  3. Validate locally with the Cube dev server to catch errors before pushing

Example fix

// before (broken model)
cube: my_cube
  sql: SELECT FROM
// after
cube: my_cube
  sql: SELECT * FROM public.events
Defensive patterns

Strategy: try-catch

Try / catch

try {
  run(`cube validate --branch ${branch}`);
} catch (e) {
  if (String(e).includes("compilation error(s)")) {
    console.error("Fix data model errors printed above before deploying");
    process.exitCode = 1;
  } else throw e;
}

Prevention

When it happens

Trigger: Running `cube validate --branch <branch>` where the API's compiler returns one or more compilation errors for the branch's data model (schema YAML/JS syntax errors, invalid cubes, bad joins).

Common situations: A recent commit introduced a broken data model file; merged PRs with conflicting schema changes; invalid environment variable references in the model.

Related errors


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