{"record":{"id":"f50ff9d748a4f44a","repo":"clockworklabs/SpacetimeDB","slug":"multiple-databases-found-in-config-please-spe","errorCode":null,"errorMessage":"Multiple databases found in config: {}. Please specify which database to use, or pass --no-config to use '{}' directly.","messagePattern":"Multiple databases found in config: (.+?)\\. Please specify which database to use, or pass --no-config to use '(.+?)' directly\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/db_arg_resolution.rs","lineNumber":44,"sourceCode":"\n#[derive(Debug, Clone, PartialEq, Eq)]\npub(crate) struct ConfigDbTarget {\n    pub database: String,\n    pub server: Option<String>,\n}\n\n#[derive(Debug, Clone, PartialEq, Eq)]\npub(crate) struct ResolvedDbArgs {\n    pub database: String,\n    pub server: Option<String>,\n    pub remaining_args: Vec<String>,\n}\n\n/// Build an error for when the first positional arg doesn't match any configured database target.\nfn unknown_database_error(db: &str, config_targets: &[ConfigDbTarget]) -> anyhow::Error {\n    let known: Vec<&str> = config_targets.iter().map(|t| t.database.as_str()).collect();\n    if known.len() > 1 {\n        anyhow::anyhow!(\n            \"Multiple databases found in config: {}. Please specify which database to use, \\\n             or pass --no-config to use '{}' directly.\",\n            known.join(\", \"),\n            db\n        )\n    } else {\n        anyhow::anyhow!(\n            \"Database '{}' is not in the config file. \\\n             If you want to run against a database outside of the current project, pass --no-config.\",\n            db\n        )\n    }\n}\n\npub(crate) fn load_config_db_targets(no_config: bool) -> anyhow::Result<Option<Vec<ConfigDbTarget>>> {\n    if no_config {\n        return Ok(None);\n    }","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/db_arg_resolution.rs#L26-L62","documentation":"db_arg_resolution's unknown_database_error with multiple configured databases: the first positional argument matched none of the database targets declared in spacetime.json, and since the config declares more than one candidate the CLI cannot silently pick one. It lists the known database names and offers --no-config as the escape hatch for addressing a database outside the project config.","triggerScenarios":"Running e.g. `spacetime logs mydb` (or publish/call/describe) inside a project whose spacetime.json declares two or more databases, where 'mydb' matches none of them.","commonSituations":"Typos in the database name; database renamed in the config but scripts still use the old name; copy-pasting a command between projects; invoking a project command against an unrelated database.","solutions":["Use one of the database names listed in the error message (they come straight from spacetime.json)","If the database was renamed, update spacetime.json (or your command) so the names agree","If you really mean an unconfigured database, pass --no-config to bypass project resolution"],"exampleFix":"# before (config declares app-db and analytics-db)\nspacetime logs mydb\n\n# after\nspacetime logs app-db","handlingStrategy":"validation","validationCode":"# Resolve the database against the config before invoking the CLI\nKNOWN=$(jq -r '.databases[].database // .modules[].database' spacetime.json)\necho \"$KNOWN\" | grep -qx \"$DB\" || { echo \"unknown db '$DB'; known: $(echo $KNOWN)\" >&2; exit 1; }\nspacetime logs \"$DB\"","typeGuard":"fn resolve_db<'a>(name: &str, targets: &'a [ConfigDbTarget]) -> Option<&'a ConfigDbTarget> {\n    targets.iter().find(|t| t.database == name)\n}","tryCatchPattern":"let out = cmd.output()?;\nif !out.status.success() {\n    let msg = String::from_utf8_lossy(&out.stderr);\n    if msg.contains(\"Multiple databases found in config\") {\n        // parse the listed names and prompt the user to pick one, then re-run with it\n    }\n}","preventionTips":["Source database names from spacetime.json (jq) rather than hard-coding them in scripts","When a database is renamed in config, grep all pipelines for the old name in the same commit"],"tags":["spacetimedb","cli","database","argument-resolution","multi-database"],"backgroundTag":"ambiguous-target-selection","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}