{"record":{"id":"b79391e2dd540580","repo":"clockworklabs/SpacetimeDB","slug":"the-following-required-arguments-were-not-provided-b79391","errorCode":null,"errorMessage":"the following required arguments were not provided:\n  <database>\n\nUsage: {}","messagePattern":"the following required arguments were not provided:\n  <database>\n\nUsage: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/db_arg_resolution.rs","lineNumber":156,"sourceCode":"    };\n    if raw_parts.len() < 2 {\n        return Err(require_arg(required_arg_name));\n    }\n\n    Ok(ResolvedDbArgs {\n        database: db.clone(),\n        server: target.server.clone(),\n        remaining_args: raw_parts[1..].to_vec(),\n    })\n}\n\npub(crate) fn resolve_database_arg(\n    raw_database: Option<&str>,\n    config_targets: Option<&[ConfigDbTarget]>,\n    usage: &str,\n) -> anyhow::Result<ResolvedDbArgs> {\n    let require_database = || {\n        anyhow::anyhow!(\n            \"the following required arguments were not provided:\\n  <database>\\n\\nUsage: {}\",\n            usage\n        )\n    };\n\n    let Some(config_targets) = config_targets else {\n        let database = raw_database.ok_or_else(require_database)?;\n        return Ok(ResolvedDbArgs {\n            database: database.to_string(),\n            server: None,\n            remaining_args: vec![],\n        });\n    };\n\n    if config_targets.len() == 1 {\n        let target = &config_targets[0];\n        if let Some(db) = raw_database\n            && db != target.database","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/db_arg_resolution.rs#L138-L174","documentation":"resolve_database_arg's no-config branch: the command needs a database, no config targets exist to supply a default, and raw_database is None (no positional and no -d/--database value), so the synthetic clap error demands <database> with the caller's usage string.","triggerScenarios":"Running a database-scoped command (e.g. `spacetime publish` with no database argument) outside a project directory, or with --no-config, so nothing can fill in the database.","commonSituations":"First commands in a fresh clone before entering the project; CI steps that run from an artifacts directory; assuming the CLI remembers a previously used database (it doesn't — the default comes only from project config).","solutions":["Pass the database name as the positional (or via the -d/--database flag) as shown in the Usage line","cd into the project directory containing spacetime.json so its default applies","Remove --no-config if project defaults were intended"],"exampleFix":"# before\nspacetime publish\n\n# after\nspacetime publish mydb","handlingStrategy":"validation","validationCode":"# Require a database (positional or -d) when no project config is present\nDB=\"${1:-$SPACETIME_DB}\"\n[ -n \"$DB\" ] || { echo 'database required (no spacetime.json found)' >&2; exit 2; }\nspacetime publish \"$DB\"","typeGuard":"fn db_arg_provided(positional: Option<&str>, flag: Option<&str>) -> bool {\n    positional.is_some() || flag.is_some()\n}","tryCatchPattern":"if ! spacetime publish $EXTRA; then\n  # on 'required arguments were not provided: <database>', re-run with the configured default:\n  spacetime publish \"$(jq -r '.databases[0].database' spacetime.json)\"\nfi","preventionTips":["In automation, always pass the database explicitly instead of relying on project-config defaults","cd into the project (or export SPACETIME_DB-style variables) before bare commands"],"tags":["spacetimedb","cli","arguments","usage","missing-argument","database"],"backgroundTag":"missing-required-argument","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}