{"record":{"id":"c0c960c856c81c02","repo":"cube-js/cube","slug":"branch-cannot-be-empty-when-used-with-wait","errorCode":null,"errorMessage":"--branch cannot be empty when used with --wait","messagePattern":"--branch cannot be empty when used with --wait","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/cube-cli/src/commands/deployments.rs","lineNumber":325,"sourceCode":"    },\n    /// Advance onboarding to a target creation step\n    AdvanceStep {\n        /// Deployment id\n        deployment: i64,\n        /// Target step: project, upload, schema, github, ssh, databases, ready, demo\n        step: String,\n    },\n    /// Reset onboarding back to the first creation step (project)\n    ResetStep {\n        /// Deployment id\n        deployment: i64,\n    },\n}\n\nfn validate_build_status_args(cmd: &Cmd) -> Result<()> {\n    if let Cmd::BuildStatus { branch, wait, .. } = cmd {\n        if *wait && branch.as_deref().is_some_and(util::is_blank) {\n            anyhow::bail!(\"--branch cannot be empty when used with --wait\");\n        }\n    }\n    Ok(())\n}\n\npub async fn command(args: Args, ctx: &Ctx) -> Result<()> {\n    validate_build_status_args(&args.cmd)?;\n    let api = ctx.api()?;\n    match args.cmd {\n        Cmd::List {\n            creation_step,\n            offset,\n            limit,\n            first,\n            after,\n        } => {\n            let page_field = util::paging_field(\n                util::OFFSET_LIMIT_IN_QUERY,","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cube-cli/src/commands/deployments.rs#L307-L343","documentation":"Argument-validation error from validate_build_status_args: the user passed --wait together with --branch whose value is empty/whitespace. Waiting requires a concrete branch to poll for, so a blank branch is rejected up front with this bail rather than producing a confusing poll or timeout later.","triggerScenarios":"`cube deployments build/status <deployment> --branch \"\" --wait` or `--branch \"   \" --wait` — typically from a shell/CI variable that interpolated to empty (e.g. unset BRANCH_NAME env var, or a script parameter that defaulted to empty string).","commonSituations":"CI pipeline where $BRANCH/$GIT_BRANCH is unset on the trigger type (e.g. tag or manual dispatch); a Makefile variable that resolves to nothing; quoting mistake dropping the value.","solutions":["Supply a non-empty branch name with --branch.","In CI, export the branch variable (e.g. branch name from the git ref) before invoking the CLI.","Drop --branch if you actually want the command's default branch behavior instead of waiting on a specific one.","Add a shell guard that fails early when the branch variable is empty."],"exampleFix":"# before: unset var expands to empty\nBRANCH=${BRANCH:-}\ncube deployments build 42 --branch \"$BRANCH\" --wait\n# after: fail fast with a clear message before invoking the CLI\n: \"${BRANCH:?BRANCH must be set}\"\ncube deployments build 42 --branch \"$BRANCH\" --wait","handlingStrategy":"validation","validationCode":"# Reject an empty branch before calling the CLI\n: \"${BRANCH:?--branch value is required when using --wait}\"\n[ -n \"${BRANCH//[[:space:]]/}\" ] || { echo \"--branch cannot be blank\"; exit 2; }","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"--branch cannot be empty\") => {\n        // fix the script's branch variable and retry once\n    }\n    other => other?,\n}","preventionTips":["Use `${VAR:?}` shell guards for branch variables in CI scripts.","Derive the branch from git (`git rev-parse --abbrev-ref HEAD`) rather than unset env vars.","Never pass --wait without a concrete branch in automation.","Trim whitespace on branch inputs before passing them through."],"tags":["cli","validation","argument-error","empty-string","ci"],"backgroundTag":"missing-or-empty-argument","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}