cube-js/cube · error

dbt sync {sync_job_id} failed: {}

Error message

dbt sync {sync_job_id} failed: {}

What it means

Raised by `cube dbt sync <deployment> --wait` after wait_for_sync observed the sync reach status FAILED. The dbt sync's underlying workflow failed (a dbt compile or warehouse error), and the CLI surfaces the workflow's own `error` field collapsed to one line; if the workflow reported no reason, it prints "(no reason reported)". The non-zero exit is the signal CI gates act on.

Source

Thrown at rust/cube-cli/src/commands/dbt.rs:328

            eprintln!("dbt sync {sync_job_id} started on {shown}");
            let status = wait_for_sync(&api, deployment, &sync_job_id, timeout, poll).await?;

            if util::status_of(&status, "status") == FAILED {
                if ctx.json {
                    output::print_json(&wait_json(&started, &status, &branch_name, None));
                }

                // The only signal a CI gate needs is the non-zero exit. The message
                // carries the workflow's own reason, which is what a human reading
                // the failed job actually wants — and `is_blank` rather than `is_empty`
                // because a reason of blanks would fill the slot without answering it,
                // on the one line somebody reads when the gate goes red.
                // Collapsed like the build failure in `deployments`: a dbt reason is a
                // compile or warehouse error that arrives multi-line, and this is a
                // `bail!` whose chain `main` renders on one line with `{err:#}`.
                let error = util::one_line(&output::field(&status, "error"), util::REASON_LIMIT);
                bail!(
                    "dbt sync {sync_job_id} failed: {}",
                    if util::is_blank(&error) {
                        "(no reason reported)".to_string()
                    } else {
                        error
                    }
                );
            }

            // COMPLETED from here on, so the result is a value rather than a
            // possibility: a sync that produced none leaves through the `Err` branch
            // below. Handling the failure above rather than carrying an `Option` this
            // far is what makes that structural instead of merely true.
            //
            // Fold the result into the same command rather than making the caller ask
            // again.
            //
            // Through `wait::poll` for two reasons. Its transient tolerance covers

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Read the reason in the message — it is the workflow's own one-line error — and fix the dbt model or warehouse issue it names.
  2. If it says "(no reason reported)", run `cube dbt result <deployment> <sync_job_id>` or check the deployment logs for the full multi-line error.
  3. Fix the offending models on the branch and start a new `cube dbt sync`.
  4. Verify dbt credentials and warehouse connectivity for the deployment.

Example fix

// before: syncing a branch without compiling locally first
cube dbt sync 42 --branch feature/etl --wait
// after: catch dbt compile errors locally before syncing
dbt compile --project-dir models && cube dbt sync 42 --branch feature/etl --wait
Defensive patterns

Strategy: try-catch

Validate before calling

// Compile dbt models locally before starting a sync
dbt compile --project-dir models || { echo 'dbt compile failed locally'; exit 1; }

Try / catch

match result {
    Err(e) if e.to_string().starts_with("dbt sync") && e.to_string().contains("failed") => {
        // surface e (the one-line workflow reason) in CI logs and mark the gate red
        std::process::exit(1);
    }
    other => other?,
}

Prevention

When it happens

Trigger: `cube dbt sync <deployment> --wait` where the polled status payload has status == "FAILED". Causes: dbt model compilation errors, warehouse query failures, invalid branch/ref content, missing dbt credentials.

Common situations: A developer pushed broken dbt models to the branch being synced; a warehouse credential or connection used by the sync expired; a dbt compilation error from a renamed/removed model; CI gating a deploy on a sync that failed against the branch.

Related errors


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