{"record":{"id":"b3825091843bdb53","repo":"cube-js/cube","slug":"provide-file-path-or-content-text","errorCode":null,"errorMessage":"provide --file <path> or --content <text>","messagePattern":"provide --file <path> or --content <text>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/cube-cli/src/commands/data_model.rs","lineNumber":321,"sourceCode":"        output::success(&format!(\n            \"Disabled branch {branch}; its staging environment is active only while viewed\"\n        ));\n    }\n    Ok(())\n}\n\nfn read_content(file: Option<String>, content: Option<String>) -> Result<String> {\n    if let Some(path) = file {\n        return std::fs::read_to_string(&path).with_context(|| format!(\"failed to read {path}\"));\n    }\n    match content.as_deref() {\n        Some(\"-\") => {\n            let mut buf = String::new();\n            std::io::stdin().read_to_string(&mut buf)?;\n            Ok(buf)\n        }\n        Some(c) => Ok(c.to_string()),\n        None => anyhow::bail!(\"provide --file <path> or --content <text>\"),\n    }\n}\n\n/// The command that opens a branch for compilation, rendered in one place.\n///\n/// Three messages hand it over — the `Branch is not active` verdict and the\n/// `none`/`stopped` backstop in [`crate::commands::deployments`], and `create-branch\n/// --dev-mode` below — and their prose deliberately differs: one answers a verdict, one\n/// answers absence, one follows a branch that was just created. What a reader COPIES\n/// shouldn't differ, so only the sentences around it are written three times. It lives\n/// here because this module owns the subcommand it names.\n///\n/// The branch is user-supplied and goes into a command meant to be pasted, so it is\n/// quoted — see [`util::shell_quote`] for what a legal ref name can do unquoted.\npub fn dev_mode_command(deployment: i64, branch: &str) -> String {\n    format!(\n        \"`cube data-model dev-mode {deployment} {}`\",\n        util::shell_quote(branch)","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cube-cli/src/commands/data_model.rs#L303-L339","documentation":"The data model write/update commands require the content to come from somewhere: a --file path, '-' for stdin, or inline --content text. read_content bails with this error when none of these were supplied, since there is nothing to send.","triggerScenarios":"Running `cube data-model put`-style commands without --file and without --content (both flags omitted); passing empty-valued flags in scripts.","commonSituations":"Scripted CI updates where a variable holding the file path was empty; users forgetting that --file and --content are mutually required alternatives; piping forgotten (expected stdin default but none configured).","solutions":["Add --content \"<text>\" with the model definition inline","Add --file <path> pointing to the model file (or --file - to read stdin)","In scripts, guard against empty variables: only invoke with --file \"$MODEL_FILE\" if non-empty","Pipe the content: cat model.yml | cube data-model put --file -"],"exampleFix":"// before\ncube data-model put --path schema/model.yml   # no content source\n// after\ncube data-model put --path schema/model.yml --file schema/model.yml","handlingStrategy":"validation","validationCode":"const hasFile = Boolean(args.file && args.file.length);\nconst hasContent = Boolean(args.content && args.content.length);\nif (!hasFile && !hasContent) { throw new Error('Pass --file <path> (or --file - for stdin) or --content <text>'); }","typeGuard":"function hasContentSource(a: { file?: string; content?: string }): a is { file: string } | { content: string } {\n  return Boolean(a.file?.length) || Boolean(a.content?.length);\n}","tryCatchPattern":"try {\n  await putDataModel(args);\n} catch (e) {\n  if (/provide --file|--content/.test(String(e))) { console.error('Supply --file or --content'); process.exit(2); }\n  throw e;\n}","preventionTips":["Always pass --file or --content explicitly in scripts","Use `--file -` with a heredoc/pipe for generated content","Quote path variables so empty shell vars are detectable","Prefer --file over --content for anything beyond a few lines"],"tags":["cli","validation","missing-argument","user-input"],"backgroundTag":"missing-required-argument","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}