{"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":185,"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":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/fdd647dfac506d0967cc4492e9fce380706c94cb/crates/cli/src/subcommands/db_arg_resolution.rs#L167-L203","documentation":"resolve_database_arg (crates/cli/src/subcommands/db_arg_resolution.rs:156) is used by commands with a dedicated optional <database> argument (logs, delete). When no config targets exist (--no-config or no spacetime.json in scope) and raw_database is None, there is nothing to fall back on, so it raises this usage error naming <database> and the command's usage line.","triggerScenarios":"Running `spacetime logs` or `spacetime delete` outside a project (no spacetime.json) without a database argument; running them with --no-config and omitting the database; a spacetime.json that exists but declares no database targets.","commonSituations":"Ad-hoc server inspection from a random directory; cleanup scripts that assumed the project config would supply the database; fresh clones where the config file is generated later.","solutions":["Pass the database explicitly: `spacetime logs <database>` / `spacetime delete <database>`.","Run the command from a directory whose spacetime.json declares the database target, so the argument is implied.","In scripts, default the argument from an environment variable (e.g. \"${SPACETIME_DB:?database required}\") to fail fast with your own message."],"exampleFix":"# before: no config, no database\nspacetime logs\n# after\nspacetime logs my-db --no-config","handlingStrategy":"validation","validationCode":"# For logs/delete outside a project, require the database up front:\nDB=\"${1:-${SPACETIME_DB:-}}\"\n[ -n \"$DB\" ] || { echo \"missing <database>; set SPACETIME_DB or pass it as the first arg\" >&2; exit 2; }\nspacetime logs \"$DB\" --no-config","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set a SPACETIME_DB-style environment default in ad-hoc shells and pass it explicitly to logs/delete.","Run operational commands from the project directory so spacetime.json supplies the database.","In automation, fail fast on a missing database argument instead of assuming config discovery will save you."],"tags":["spacetimedb","cli","usage","missing-argument","database"],"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"}