{"record":{"id":"86ecea289a471f39","repo":"clockworklabs/SpacetimeDB","slug":"the-following-required-arguments-were-not-provided","errorCode":null,"errorMessage":"the following required arguments were not provided:\n  <{}>\n\nUsage: {}","messagePattern":"the following required arguments were not provided:\n  <(.+?)>\n\nUsage: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/db_arg_resolution.rs","lineNumber":91,"sourceCode":"                    Some(ConfigDbTarget {\n                        database: database.to_string(),\n                        server,\n                    })\n                })\n                .unique_by(|t| t.database.clone())\n                .collect::<Vec<_>>()\n        })\n        .filter(|targets| !targets.is_empty()))\n}\n\npub(crate) fn resolve_optional_database_parts(\n    raw_parts: &[String],\n    config_targets: Option<&[ConfigDbTarget]>,\n    required_arg_name: &str,\n    usage: &str,\n) -> anyhow::Result<ResolvedDbArgs> {\n    let require_arg = |name: &str| {\n        anyhow::anyhow!(\n            \"the following required arguments were not provided:\\n  <{}>\\n\\nUsage: {}\",\n            name,\n            usage\n        )\n    };\n\n    let Some(config_targets) = config_targets else {\n        if raw_parts.len() < 2 {\n            return if raw_parts.is_empty() {\n                Err(require_arg(\"database\"))\n            } else {\n                Err(require_arg(required_arg_name))\n            };\n        }\n        return Ok(ResolvedDbArgs {\n            database: raw_parts[0].clone(),\n            server: None,\n            remaining_args: raw_parts[1..].to_vec(),","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/db_arg_resolution.rs#L73-L109","documentation":"resolve_optional_database_parts, in its no-config branch, reproduces clap's 'missing required arguments' error by hand: when there are no config targets, zero positional parts demand <database>, and a single positional part demands the command-specific required argument (required_arg_name, supplied by the calling subcommand). The Usage string is provided by the caller, so the message always shows the exact syntax for the command you ran.","triggerScenarios":"Running a command that takes a database plus a required trailing argument (usage shown in the error) with too few positionals, while no spacetime.json supplies defaults — e.g. outside a project or with --no-config.","commonSituations":"Running CLI commands from $HOME or a non-project directory and assuming flags replace positionals; adding --no-config to a command that then loses config-supplied defaults; scripts written against a project context but run standalone.","solutions":["Supply the missing positional(s) exactly as shown in the Usage line of the error","Run the command from within the project so spacetime.json supplies the database default","Drop --no-config if you did intend to use the project's defaults"],"exampleFix":"# before (outside any project)\nspacetime describe\n\n# after\nspacetime describe mydb reducer my_reducer","handlingStrategy":"validation","validationCode":"# Enforce the positional contract before invoking a two-positional command\nif [ $# -lt 2 ]; then\n  echo \"usage: $0 <database> <$(basename \"$0\" -wrapper)>\" >&2; exit 2\nfi\nspacetime describe \"$1\" \"$2\" \"$3\"","typeGuard":"fn valid_positionals(parts: &[String]) -> bool {\n    !parts.is_empty() && parts.len() >= 2\n}","tryCatchPattern":"let out = cmd.output()?;\nif !out.status.success() && String::from_utf8_lossy(&out.stderr).contains(\"required arguments were not provided\") {\n    // print the Usage line from the message and surface it as a usage error (exit 2)\n}","preventionTips":["Wrap spacetime calls in scripts that assert argument counts first, mirroring the Usage line","Run config-dependent commands from the project root so spacetime.json fills defaults"],"tags":["spacetimedb","cli","arguments","usage","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}