{"record":{"id":"a956595999f69f5c","repo":"cube-js/cube","slug":"no-result-for-dbt-sync-sync-job-id-yet-check","errorCode":null,"errorMessage":"no result for dbt sync {sync_job_id} yet — check `cube dbt status {deployment} {}`","messagePattern":"no result for dbt sync (.+?) yet — check `cube dbt status (.+?) (.+?)`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"rust/cube-cli/src/commands/dbt.rs","lineNumber":463,"sourceCode":"            let query: Query = Vec::new();\n            let path = format!(\"{}/{sync_job_id}\", base(deployment));\n            match api.get_optional(&path, &query).await? {\n                Some(status) => print_status(ctx.json, &status),\n                None => bail!(\n                    \"no dbt sync {sync_job_id} on deployment {deployment} \\\n                     (it may not be visible yet, belong to another deployment, or have aged out)\"\n                ),\n            }\n        }\n        Cmd::Result {\n            deployment,\n            sync_job_id,\n        } => {\n            let path = format!(\"{}/{sync_job_id}/result\", base(deployment));\n            match available_result(api.get_optional(&path, &Vec::new()).await?) {\n                Some(result) => print_result(ctx.json, &result),\n                // A running sync, `200 null`, and `{}` all mean \"not available yet\".\n                None => bail!(\n                    \"no result for dbt sync {sync_job_id} yet — check \\\n                     `cube dbt status {deployment} {}`\",\n                    util::shell_quote(&sync_job_id)\n                ),\n            }\n        }\n        Cmd::Cancel {\n            deployment,\n            sync_job_id,\n        } => {\n            let res = api\n                .delete(&format!(\"{}/{sync_job_id}\", base(deployment)), None)\n                .await?;\n            if ctx.json {\n                output::print_json(&res);\n            } else {\n                output::success(&format!(\"Cancelled dbt sync {sync_job_id}\"));\n            }","sourceCodeStart":445,"sourceCodeEnd":481,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cube-cli/src/commands/dbt.rs#L445-L481","documentation":"Raised by `cube dbt result <deployment> <sync_job_id>` when no result document is available for the sync job. A running sync, a `200 null` response, and an empty `{}` object all normalize to \"not available yet\" via available_result(). This is a state error, not a transport failure — the CLI points the user at `cube dbt status ... --wait` to learn when the result will exist.","triggerScenarios":"`cube dbt result <deployment> <sync_job_id>` where the GET .../<sync_job_id>/result returns None, null, or {} — i.e. the sync is still RUNNING/PENDING, or just reached COMPLETED but the result document has not been written yet.","commonSituations":"Calling `dbt result` right after `dbt sync` without waiting for completion; a CI script that polls result instead of status; querying a result the instant the sync finished while the worker is still closing out the run.","solutions":["Run `cube dbt status <deployment> <sync_job_id> --wait` first and call `dbt result` only after status is COMPLETED.","If the status is FAILED, there will never be a result — fix the sync failure instead.","Add a short retry/poll around the result call if you must fetch immediately after completion.","Verify the sync_job_id is for a finished job on the right deployment."],"exampleFix":"// before: result fetched unconditionally\ncube dbt sync 42\nSYNC_ID=<id> cube dbt result 42 $SYNC_ID   # fails while sync still runs\n// after: gate on status --wait\ncube dbt sync 42 --branch x --wait && cube dbt result 42 <id>","handlingStrategy":"retry","validationCode":"// Only fetch the result after the sync is terminal\nlet status = wait_for_status_terminal(...).await?;\nif status_of(&status, \"status\") != \"COMPLETED\" {\n    anyhow::bail!(\"sync not completed; result unavailable\");\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"no result for dbt sync\") => {\n        // poll `cube dbt status --wait` then retry the result fetch\n    }\n    other => other?,\n}","preventionTips":["Gate `dbt result` on `dbt status --wait` reporting COMPLETED.","Remember a FAILED sync never yields a result — check status first.","Allow a short poll window after COMPLETED; result writing lags slightly.","In scripts, chain commands: `dbt sync --wait && dbt result`."],"tags":["cli","dbt","not-ready","polling","race-condition"],"backgroundTag":"resource-not-ready","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}