{"record":{"id":"8b79f3633675923a","repo":"cube-js/cube","slug":"dbt-sync-sync-job-id-failed","errorCode":null,"errorMessage":"dbt sync {sync_job_id} failed: {}","messagePattern":"dbt sync (.+?) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/cube-cli/src/commands/dbt.rs","lineNumber":328,"sourceCode":"\n            eprintln!(\"dbt sync {sync_job_id} started on {shown}\");\n            let status = wait_for_sync(&api, deployment, &sync_job_id, timeout, poll).await?;\n\n            if util::status_of(&status, \"status\") == FAILED {\n                if ctx.json {\n                    output::print_json(&wait_json(&started, &status, &branch_name, None));\n                }\n\n                // The only signal a CI gate needs is the non-zero exit. The message\n                // carries the workflow's own reason, which is what a human reading\n                // the failed job actually wants — and `is_blank` rather than `is_empty`\n                // because a reason of blanks would fill the slot without answering it,\n                // on the one line somebody reads when the gate goes red.\n                // Collapsed like the build failure in `deployments`: a dbt reason is a\n                // compile or warehouse error that arrives multi-line, and this is a\n                // `bail!` whose chain `main` renders on one line with `{err:#}`.\n                let error = util::one_line(&output::field(&status, \"error\"), util::REASON_LIMIT);\n                bail!(\n                    \"dbt sync {sync_job_id} failed: {}\",\n                    if util::is_blank(&error) {\n                        \"(no reason reported)\".to_string()\n                    } else {\n                        error\n                    }\n                );\n            }\n\n            // COMPLETED from here on, so the result is a value rather than a\n            // possibility: a sync that produced none leaves through the `Err` branch\n            // below. Handling the failure above rather than carrying an `Option` this\n            // far is what makes that structural instead of merely true.\n            //\n            // Fold the result into the same command rather than making the caller ask\n            // again.\n            //\n            // Through `wait::poll` for two reasons. Its transient tolerance covers","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cube-cli/src/commands/dbt.rs#L310-L346","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","solutions":["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.","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.","Fix the offending models on the branch and start a new `cube dbt sync`.","Verify dbt credentials and warehouse connectivity for the deployment."],"exampleFix":"// before: syncing a branch without compiling locally first\ncube dbt sync 42 --branch feature/etl --wait\n// after: catch dbt compile errors locally before syncing\ndbt compile --project-dir models && cube dbt sync 42 --branch feature/etl --wait","handlingStrategy":"try-catch","validationCode":"// Compile dbt models locally before starting a sync\ndbt compile --project-dir models || { echo 'dbt compile failed locally'; exit 1; }","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().starts_with(\"dbt sync\") && e.to_string().contains(\"failed\") => {\n        // surface e (the one-line workflow reason) in CI logs and mark the gate red\n        std::process::exit(1);\n    }\n    other => other?,\n}","preventionTips":["Run `dbt compile`/`dbt build` locally or in a prior CI step before syncing.","Keep deployment dbt credentials and warehouse connections current.","Gate merges on a sync of the feature branch so failures surface before prod deploys.","Treat a non-zero exit plus the one-line reason as the canonical failure signal in CI."],"tags":["cli","dbt","sync-failed","ci-gate","warehouse"],"backgroundTag":"dbt-sync-failed","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}