{"record":{"id":"38ee52647ddb0c6e","repo":"clockworklabs/SpacetimeDB","slug":"database-is-not-in-the-config-file-if-you-wa","errorCode":null,"errorMessage":"Database '{}' is not in the config file. If you want to run against a database outside of the current project, pass --no-config.","messagePattern":"Database '(.+?)' is not in the config file\\. If you want to run against a database outside of the current project, pass --no-config\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/db_arg_resolution.rs","lineNumber":51,"sourceCode":"#[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    }\n\n    Ok(find_and_load_with_env(None)?\n        .map(|loaded| {\n            loaded\n                .config\n                .collect_all_targets_with_inheritance()\n                .iter()","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/db_arg_resolution.rs#L33-L69","documentation":"The single-database variant of unknown_database_error: the supplied database name doesn't match the one database declared in spacetime.json. With exactly one candidate the message drops the list and keeps the same remedies — use the configured name, or --no-config for a database outside the project.","triggerScenarios":"`spacetime <cmd> <name>` inside a project whose spacetime.json declares exactly one database whose name differs from <name>.","commonSituations":"The database was renamed in spacetime.json during a refactor and scripts use the old name; using a historical or default name like 'database' instead of the configured one.","solutions":["Run the command with the database name from spacetime.json (or omit it to let the single entry resolve)","Update spacetime.json if the intended database name changed there","Pass --no-config to target a database not managed by this project's config"],"exampleFix":"# before (spacetime.json declares \"database\": \"app-db\")\nspacetime logs database\n\n# after\nspacetime logs app-db","handlingStrategy":"validation","validationCode":"# Single-database projects: read the real name from config\nDB=$(jq -r '.databases[0].database // .modules[0].database' spacetime.json)\nspacetime logs \"$DB\"","typeGuard":"fn is_configured_db(name: &str, targets: &[ConfigDbTarget]) -> bool {\n    targets.iter().any(|t| t.database == name)\n}","tryCatchPattern":"if stderr contains \"is not in the config file\" {\n    // either correct the name from `spacetime.json` or re-run with --no-config for out-of-project databases\n}","preventionTips":["Don't assume a default database name; always resolve it from spacetime.json","Reserve --no-config for deliberate out-of-project operations so misnamed calls fail loudly"],"tags":["spacetimedb","cli","database","argument-resolution","config"],"backgroundTag":"config-entry-not-found","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}