{"record":{"id":"8134fd970409c1c7","repo":"clockworklabs/SpacetimeDB","slug":"invalid-subcommand-unknown","errorCode":null,"errorMessage":"Invalid subcommand: {unknown}","messagePattern":"Invalid subcommand: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/lib.rs","lineNumber":80,"sourceCode":"        \"env\" => env::exec(config, args).await,\n        \"delete\" => delete::exec(config, args).await,\n        \"logs\" => logs::exec(config, args).await,\n        \"sql\" => sql::exec(config, args).await,\n        \"mcp\" => mcp::exec(config, args).await,\n        \"rename\" => dns::exec(config, args).await,\n        \"generate\" => generate::exec(config, args).await,\n        \"list\" => list::exec(config, args).await,\n        \"init\" => init::exec(config, args).await.map(|_| ()),\n        \"build\" => build::exec(config, args).await.map(drop),\n        \"server\" => server::exec(config, paths, args).await,\n        \"subscribe\" => subscribe::exec(config, args).await,\n        \"start\" => return start::exec(config, paths, args).await,\n        \"login\" => login::exec(config, args).await,\n        \"logout\" => logout::exec(config, args).await,\n        \"lock\" => lock::exec(config, args).await,\n        \"unlock\" => unlock::exec(config, args).await,\n        \"version\" => return subcommands::version::exec(paths, root_dir, args).await,\n        unknown => Err(anyhow::anyhow!(\"Invalid subcommand: {unknown}\")),\n    }\n    .map(|()| ExitCode::SUCCESS)\n}\n\n/// An error type indicating that the process should exit silently with the\n/// given `ExitCode`.\n#[derive(thiserror::Error, Debug)]\n#[error(\"exit with {0:?}\")]\npub struct ExitWithCode(pub ExitCode);\n\nimpl ExitWithCode {\n    /// Basic unsuccessful termination.\n    pub const FAILURE: Self = ExitWithCode(ExitCode::FAILURE);\n}\n","sourceCodeStart":62,"sourceCodeEnd":95,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/cli/src/lib.rs#L62-L95","documentation":"The CLI's exec (crates/cli/src/lib.rs:77) matches the first positional word against its subcommand table (generate, list, init, build, server, subscribe, start, login, logout, lock, unlock, version, and the arms above the shown region) and falls through to this bail for anything unrecognized. It is the last-resort arm of the dispatcher, so every typo, removed, or not-yet-installed subcommand lands here.","triggerScenarios":"Running `spacetime <word>` where word is misspelled or not a subcommand (e.g. `spacetime publis`); using a subcommand that was renamed or removed in the installed CLI version; invoking a plugin-style subcommand that this build does not include.","commonSituations":"Following outdated docs or tutorials against a newer/older CLI; shell autocompletion from another tool; scripts written for a different SpacetimeDB CLI version.","solutions":["Run `spacetime --help` and use the exact subcommand name listed for your installed version.","Check for typos and case (subcommands are lowercase single words).","After upgrading the CLI, re-check the changelog/help for renamed subcommands and update scripts."],"exampleFix":"# before\nspacetime publis my-project\n# after\nspacetime publish my-project","handlingStrategy":"validation","validationCode":"// Shell: validate the subcommand against the CLI's own help before running.\nvalid=$(spacetime --help 2>&1 | awk '/^Commands:/,/^Options:/' | awk '{print $1}' | grep -vx '^Commands:')\necho \"$valid\" | grep -qx \"$1\" || { echo \"unknown subcommand: $1 (valid: $(echo $valid | tr '\\n' ' '))\" >&2; exit 2; }","typeGuard":"// Rust embedding the CLI name as a word-check:\nconst SUBCOMMANDS: &[&str] = &[\"generate\", \"list\", \"init\", \"build\", \"server\", \"subscribe\", \"start\", \"login\", \"logout\", \"lock\", \"unlock\", \"version\"];\nfn is_subcommand(word: &str) -> bool { SUBCOMMANDS.contains(&word) }","tryCatchPattern":null,"preventionTips":["Pin your docs/tutorials to the CLI version your team uses; re-check `spacetime --help` after upgrades.","In scripts, fail fast on unknown subcommands by validating against help output (or shell completion) first.","Enable shell completion for spacetime so typos surface at typing time."],"tags":["spacetimedb","cli","usage","unknown-command"],"backgroundTag":"unknown-command","analyzedSha":"eddf9f5014579a50d4b67630e28b6e15cad9c4af","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}