clockworklabs/SpacetimeDB · error
Multiple databases found in config: {}. Please specify which
Error message
Multiple databases found in config: {}. Please specify which database to use, or pass --no-config to use '{}' directly. What it means
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.
Source
Thrown at crates/cli/src/subcommands/db_arg_resolution.rs:44
#[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 524b4487d9)
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
Example fix
# before (config declares app-db and analytics-db) spacetime logs mydb # after spacetime logs app-db
Defensive patterns
Strategy: validation
Validate before calling
# Resolve the database against the config before invoking the CLI
KNOWN=$(jq -r '.databases[].database // .modules[].database' spacetime.json)
echo "$KNOWN" | grep -qx "$DB" || { echo "unknown db '$DB'; known: $(echo $KNOWN)" >&2; exit 1; }
spacetime logs "$DB" Type guard
fn resolve_db<'a>(name: &str, targets: &'a [ConfigDbTarget]) -> Option<&'a ConfigDbTarget> {
targets.iter().find(|t| t.database == name)
} Try / catch
let out = cmd.output()?;
if !out.status.success() {
let msg = String::from_utf8_lossy(&out.stderr);
if msg.contains("Multiple databases found in config") {
// parse the listed names and prompt the user to pick one, then re-run with it
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Database '{}' is not in the config file. If you want to run
- the following required arguments were not provided: <datab
- Manual database migrations are not yet implemented
- Unsupported --dotnet-version {version}. Supported values: 8,
- No such saved server configuration: {server} Add a new serve
AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16).
Data as JSON: /api/errors/f50ff9d748a4f44a.
Report an issue: GitHub.