{"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":120,"sourceCode":"fn single_config_server(config: &SpacetimeConfig) -> Option<String> {\n    config\n        .collect_all_targets_with_inheritance()\n        .iter()\n        .filter_map(|target| target.fields.get(\"server\").and_then(|v| v.as_str()))\n        .unique()\n        .exactly_one()\n        .ok()\n        .map(str::to_string)\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":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/fdd647dfac506d0967cc4492e9fce380706c94cb/crates/cli/src/subcommands/db_arg_resolution.rs#L102-L138","documentation":"resolve_optional_database_parts (crates/cli/src/subcommands/db_arg_resolution.rs:91) emits a clap-style usage error when there are no config targets (--no-config passed, or no spacetime.json found) and fewer than two raw positionals remain: an empty invocation reports the missing <database>, while a single positional reports the command-specific required argument (e.g. <function_name> for call, the query for subscribe). Without config, both the database and the command's own argument must be supplied positionally.","triggerScenarios":"Running `spacetime call --no-config` (nothing supplied: reports <database>) or `spacetime call mydb --no-config` (only the database: reports <function_name>); running call/subscribe outside any project directory with no spacetime.json and incomplete positionals.","commonSituations":"Scripts written for a configured project run on machines without the config; CI jobs that always pass --no-config but were authored expecting config-implied defaults; shell loops that sometimes produce an empty arguments list.","solutions":["Supply both positionals when using --no-config: `spacetime call <database> <function_name> <args...> --no-config` (same shape for subscribe with its query).","Or run from a directory containing a spacetime.json defining the database, so the database part can be omitted.","Guard scripts by checking `$#` before invoking so the usage error never reaches the CLI."],"exampleFix":"# before: no config, missing function name\nspacetime call mydb --no-config\n# after\nspacetime call mydb my-reducer '[1,2]' --no-config","handlingStrategy":"validation","validationCode":"# When using --no-config, require at least database + the command's own first arg:\nusage() { echo \"usage: $(basename \"$0\") <database> <function_name> [args...]\" >&2; exit 2; }\n[ \"$#\" -ge 2 ] || usage\nspacetime call \"$@\" --no-config","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat --no-config as 'all parts explicit': always pass both the database and the command argument.","Validate positional count in wrapper scripts before invoking the CLI so users get your usage text, not the CLI's.","Document for your team which commands imply the database from config and which require it positionally."],"tags":["spacetimedb","cli","usage","missing-argument","no-config"],"backgroundTag":"missing-required-argument","analyzedSha":"fdd647dfac506d0967cc4492e9fce380706c94cb","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}