cube-js/cube · error

--branch cannot be empty when used with --wait

Error message

--branch cannot be empty when used with --wait

What it means

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.

Source

Thrown at rust/cube-cli/src/commands/deployments.rs:325

    },
    /// Advance onboarding to a target creation step
    AdvanceStep {
        /// Deployment id
        deployment: i64,
        /// Target step: project, upload, schema, github, ssh, databases, ready, demo
        step: String,
    },
    /// Reset onboarding back to the first creation step (project)
    ResetStep {
        /// Deployment id
        deployment: i64,
    },
}

fn validate_build_status_args(cmd: &Cmd) -> Result<()> {
    if let Cmd::BuildStatus { branch, wait, .. } = cmd {
        if *wait && branch.as_deref().is_some_and(util::is_blank) {
            anyhow::bail!("--branch cannot be empty when used with --wait");
        }
    }
    Ok(())
}

pub async fn command(args: Args, ctx: &Ctx) -> Result<()> {
    validate_build_status_args(&args.cmd)?;
    let api = ctx.api()?;
    match args.cmd {
        Cmd::List {
            creation_step,
            offset,
            limit,
            first,
            after,
        } => {
            let page_field = util::paging_field(
                util::OFFSET_LIMIT_IN_QUERY,

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Supply a non-empty branch name with --branch.
  2. In CI, export the branch variable (e.g. branch name from the git ref) before invoking the CLI.
  3. Drop --branch if you actually want the command's default branch behavior instead of waiting on a specific one.
  4. Add a shell guard that fails early when the branch variable is empty.

Example fix

# before: unset var expands to empty
BRANCH=${BRANCH:-}
cube deployments build 42 --branch "$BRANCH" --wait
# after: fail fast with a clear message before invoking the CLI
: "${BRANCH:?BRANCH must be set}"
cube deployments build 42 --branch "$BRANCH" --wait
Defensive patterns

Strategy: validation

Validate before calling

# Reject an empty branch before calling the CLI
: "${BRANCH:?--branch value is required when using --wait}"
[ -n "${BRANCH//[[:space:]]/}" ] || { echo "--branch cannot be blank"; exit 2; }

Try / catch

match result {
    Err(e) if e.to_string().contains("--branch cannot be empty") => {
        // fix the script's branch variable and retry once
    }
    other => other?,
}

Prevention

When it happens

Trigger: `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).

Common situations: 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.

Related errors


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