clockworklabs/SpacetimeDB · error
Multiple databases found in config
Error message
Multiple databases found in config: {}. Please specify which database to use, or pass --no-config to use '{}' directly. What it means
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.
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`.
Example fix
# before: 'baz' matches no configured target (foo, bar) spacetime subscribe baz 'SELECT * FROM Player' # after: either use a configured target spacetime subscribe foo 'SELECT * FROM Player' # or bypass the config spacetime subscribe baz 'SELECT * FROM Player' --no-config
Defensive patterns
Strategy: validation
Validate before calling
# Before running ambiguous-arg commands, check the word against configured targets: targets=$(jq -r '.databases | to_entries[] | .value.database' spacetime.json 2>/dev/null) if [ -n "$targets" ] && [ "$(wc -l <<< "$targets")" -gt 1 ] && ! grep -qx "$1" <<< "$targets"; then echo "'$1' is not a configured database (configured: $(echo $targets))" >&2; exit 2 fi
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Database ' ' is not in the config file. If you want to run…
- Failed to parse config file
- Unable to parse invalid saved server fingerprint as ECDSA…
- Cannot extract accessor name from query
- Cannot extract table name from query
AI-assisted analysis of clockworklabs/SpacetimeDB@fdd647dfac (2026-08-20).
Data as JSON: /api/errors/f50ff9d748a4f44a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/subcommands/db_arg_resolution.rs:48
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct ConfigDbTarget {
pub database: String,
pub server: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct ResolvedDbArgs {
pub database: String,
pub server: Option<String>,
pub remaining_args: Vec<String>,
}
/// Build an error for when the first positional arg doesn't match any configured database target.
fn unknown_database_error(db: &str, config_targets: &[ConfigDbTarget]) -> anyhow::Error {
let known: Vec<&str> = config_targets.iter().map(|t| t.database.as_str()).collect();
if known.len() > 1 {
anyhow::anyhow!(
"Multiple databases found in config: {}. Please specify which database to use, \
or pass --no-config to use '{}' directly.",
known.join(", "),
db
)
} else {
anyhow::anyhow!(
"Database '{}' is not in the config file. \
If you want to run against a database outside of the current project, pass --no-config.",
db
)
}
}
pub(crate) fn load_config_db_targets(no_config: bool) -> anyhow::Result<Option<Vec<ConfigDbTarget>>> {
if no_config {
return Ok(None);
}View on GitHub (pinned to fdd647dfac)