{"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":48,"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":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/fdd647dfac506d0967cc4492e9fce380706c94cb/crates/cli/src/subcommands/db_arg_resolution.rs#L30-L66","documentation":"When a spacetime.json defines multiple database targets and the first positional argument of `call`/`subscribe`/`describe` (resolve_optional_database_parts / resolve_database_with_optional_parts, crates/cli/src/subcommands/db_arg_resolution.rs:44) doesn't match any configured target name, the CLI cannot know whether the word is a database or the command's own first argument, so it errors and lists all configured database names. Unlike `logs`/`delete`/`sql`, these commands cannot auto-fall through because their first positional is ambiguous.","triggerScenarios":"Running `spacetime call some-name ...` or `spacetime subscribe some-name 'SELECT 1'` in a project whose spacetime.json declares two or more databases (e.g. foo on maincloud, bar on local) and some-name matches neither; misspelling a configured alias.","commonSituations":"Monorepos where one spacetime.json serves several databases; scripts written when the project had a single target, run after a second target was added; typos in configured database names.","solutions":["Use one of the listed configured names as the first argument: `spacetime call <listed-name> ...`.","Add the intended database as a target in spacetime.json so its name resolves.","Pass --no-config to address the database directly without config resolution: `spacetime call <name-or-identity> <fn> <args> --no-config`."],"exampleFix":"# before: 'baz' matches no configured target (foo, bar)\nspacetime subscribe baz 'SELECT * FROM Player'\n# after: either use a configured target\nspacetime subscribe foo 'SELECT * FROM Player'\n# or bypass the config\nspacetime subscribe baz 'SELECT * FROM Player' --no-config","handlingStrategy":"validation","validationCode":"# Before running ambiguous-arg commands, check the word against configured targets:\ntargets=$(jq -r '.databases | to_entries[] | .value.database' spacetime.json 2>/dev/null)\nif [ -n \"$targets\" ] && [ \"$(wc -l <<< \"$targets\")\" -gt 1 ] && ! grep -qx \"$1\" <<< \"$targets\"; then\n  echo \"'$1' is not a configured database (configured: $(echo $targets))\" >&2; exit 2\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In multi-database projects, always prefix call/subscribe/describe with an exact configured target name.","Keep a single source of truth for target names (the spacetime.json) and generate scripts from it.","Add --no-config deliberately when you mean an ad-hoc database, so resolution never guesses."],"tags":["spacetimedb","cli","config","database-targets","ambiguous-arg"],"backgroundTag":"ambiguous-database-target","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"}