{"record":{"id":"8c9a2e17e8625ca9","repo":"cube-js/cube","slug":"required-is-required-or-provide-it-via-data","errorCode":null,"errorMessage":"--{required} is required (or provide it via --data)","messagePattern":"--(.+?) is required \\(or provide it via --data\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/cube-cli/src/commands/deployments.rs","lineNumber":405,"sourceCode":"            unmanaged,\n            creation_step,\n            bootstrap,\n            data,\n        } => {\n            // Flags populate the body; --data (if given) overrides them.\n            let mut body = serde_json::Map::new();\n            util::set(&mut body, \"name\", &name);\n            util::set(&mut body, \"region\", &region);\n            body.insert(\"cloudProvider\".into(), serde_json::json!(cloud_provider));\n            body.insert(\"targetPlatform\".into(), serde_json::json!(target_platform));\n            body.insert(\"isManaged\".into(), serde_json::json!(!unmanaged));\n            body.insert(\"creationStep\".into(), serde_json::json!(creation_step));\n            for (k, v) in util::parse_data(data.as_deref())? {\n                body.insert(k, v);\n            }\n            for required in [\"name\", \"region\"] {\n                if !body.contains_key(required) {\n                    anyhow::bail!(\"--{required} is required (or provide it via --data)\");\n                }\n            }\n            // Deployment creation is build-served: it scaffolds the project\n            // (unless creationMethod says otherwise) and runs the first\n            // build. The old row-only POST /api/v1/deployments is gone —\n            // --bootstrap is kept as a hidden no-op for compatibility.\n            let _ = bootstrap;\n            let res = api\n                .post(\"/build/api/v1/deployments\", Some(&util::body(body)))\n                .await?;\n            output::print_json(&res);\n        }\n        Cmd::Update {\n            deployment,\n            name,\n            release_channel,\n            release_channel_version,\n            data,","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cube-cli/src/commands/deployments.rs#L387-L423","documentation":"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.","triggerScenarios":"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').","commonSituations":"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'.","solutions":["Pass --name <name> and --region <region> explicitly on the command line","Or include \"name\" and \"region\" keys in the JSON passed via --data","Check --data JSON for typos or nested structure — keys must be top-level 'name' and 'region'"],"exampleFix":"// before\ncube deployments create --data '{\"name\":\"my-proj\"}'\n// after\ncube deployments create --name my-proj --region us-west1","handlingStrategy":"validation","validationCode":"const required = [\"name\", \"region\"];\nfor (const k of required) {\n  if (!(k in body)) throw new Error(`--${k} is required (or provide it via --data)`);\n}","typeGuard":"const hasRequired = (b: Record<string, unknown>): b is Record<string, unknown> & { name: string; region: string } =>\n  typeof b.name === \"string\" && typeof b.region === \"string\";","tryCatchPattern":"try {\n  execSync(`cube deployments create --data '${json}'`, { stdio: \"inherit\" });\n} catch (e) {\n  if (String(e).includes(\"is required (or provide it via --data)\")) fixBodyAndRetry();\n  else throw e;\n}","preventionTips":["Always pass --name and --region explicitly instead of relying on --data","Validate --data JSON keys against the required list in scripts before invoking","Keep a shell function/wrapper that enforces the two flags"],"tags":["cli","missing-argument","deployments"],"backgroundTag":"missing-required-argument","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}