cube-js/cube · error

--{required} is required (or provide it via --data)

Error message

--{required} is required (or provide it via --data)

What it means

This error comes from the `cube deployments create` command in the Cube CLI. Creating a deployment requires at least a name and a region; these can be passed either as dedicated CLI flags (--name, --region) or supplied as JSON key/value pairs via --data. The CLI bails out when, after merging flags and --data, the request body still lacks one of the required keys.

Source

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

            unmanaged,
            creation_step,
            bootstrap,
            data,
        } => {
            // Flags populate the body; --data (if given) overrides them.
            let mut body = serde_json::Map::new();
            util::set(&mut body, "name", &name);
            util::set(&mut body, "region", &region);
            body.insert("cloudProvider".into(), serde_json::json!(cloud_provider));
            body.insert("targetPlatform".into(), serde_json::json!(target_platform));
            body.insert("isManaged".into(), serde_json::json!(!unmanaged));
            body.insert("creationStep".into(), serde_json::json!(creation_step));
            for (k, v) in util::parse_data(data.as_deref())? {
                body.insert(k, v);
            }
            for required in ["name", "region"] {
                if !body.contains_key(required) {
                    anyhow::bail!("--{required} is required (or provide it via --data)");
                }
            }
            // Deployment creation is build-served: it scaffolds the project
            // (unless creationMethod says otherwise) and runs the first
            // build. The old row-only POST /api/v1/deployments is gone —
            // --bootstrap is kept as a hidden no-op for compatibility.
            let _ = bootstrap;
            let res = api
                .post("/build/api/v1/deployments", Some(&util::body(body)))
                .await?;
            output::print_json(&res);
        }
        Cmd::Update {
            deployment,
            name,
            release_channel,
            release_channel_version,
            data,

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Pass --name <name> and --region <region> explicitly on the command line
  2. Or include "name" and "region" keys in the JSON passed via --data
  3. Check --data JSON for typos or nested structure — keys must be top-level 'name' and 'region'

Example fix

// before
cube deployments create --data '{"name":"my-proj"}'
// after
cube deployments create --name my-proj --region us-west1
Defensive patterns

Strategy: validation

Validate before calling

const required = ["name", "region"];
for (const k of required) {
  if (!(k in body)) throw new Error(`--${k} is required (or provide it via --data)`);
}

Type guard

const hasRequired = (b: Record<string, unknown>): b is Record<string, unknown> & { name: string; region: string } =>
  typeof b.name === "string" && typeof b.region === "string";

Try / catch

try {
  execSync(`cube deployments create --data '${json}'`, { stdio: "inherit" });
} catch (e) {
  if (String(e).includes("is required (or provide it via --data)")) fixBodyAndRetry();
  else throw e;
}

Prevention

When it happens

Trigger: Running `cube deployments create` without --name or --region, and without those keys present in the JSON passed via --data (or a misspelled key in --data, e.g. 'regionName' instead of 'region').

Common situations: Scripting deployment creation where --data was built from a config file with missing or renamed keys; copy-pasting examples that use different flag names; forgetting that --data keys must exactly match 'name' and 'region'.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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