{"record":{"id":"e1a8d219ad651106","repo":"clockworklabs/SpacetimeDB","slug":"cannot-use-module-specific-arguments-when","errorCode":null,"errorMessage":"Cannot use module-specific arguments ({}) when {}. {}","messagePattern":"Cannot use module-specific arguments \\((.+?)\\) when (.+?)\\. (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/spacetime_config.rs","lineNumber":530,"sourceCode":"    /// Validate that module-specific CLI flags are not used when operating on multiple targets.\n    pub fn validate_no_module_specific_cli_args_for_multiple_targets(\n        &self,\n        command: &Command,\n        matches: &ArgMatches,\n        target_count: usize,\n        operation_context: &str,\n        resolution_hint: &str,\n    ) -> anyhow::Result<()> {\n        if target_count <= 1 {\n            return Ok(());\n        }\n\n        let display_args = self.module_specific_cli_flags(command, matches);\n        if display_args.is_empty() {\n            return Ok(());\n        }\n\n        anyhow::bail!(\n            \"Cannot use module-specific arguments ({}) when {}. {}\",\n            display_args.join(\", \"),\n            operation_context,\n            resolution_hint\n        );\n    }\n\n    /// Get all generate-entry-specific keys that were provided via CLI.\n    pub fn generate_entry_specific_cli_args(&self, matches: &ArgMatches) -> Vec<&str> {\n        self.keys\n            .iter()\n            .filter(|k| k.generate_entry_specific && self.is_from_cli(matches, k.config_name()))\n            .map(|k| k.config_name())\n            .collect()\n    }\n\n    /// Get user-facing CLI flags for generate-entry-specific options provided via CLI.\n    pub fn generate_entry_specific_cli_flags(&self, command: &Command, matches: &ArgMatches) -> Vec<String> {","sourceCodeStart":512,"sourceCodeEnd":548,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/cli/src/spacetime_config.rs#L512-L548","documentation":"A guard in the CLI's config plumbing: when an operation resolves to more than one target (multiple publish/generate entries in spacetime.json), CLI flags classified as module-specific are rejected because there is no single module to apply them to. The message lists the offending flags plus an operation context and a hint for narrowing to one target.","triggerScenarios":"Running a publish/generate operation with 2+ resolved targets while any module-specific CLI flag is present, where the flag's config key is marked module-specific for that command.","commonSituations":"A spacetime.json with several publish targets plus CLI flags intended for just one of them; migrating a single-module workflow to a multi-module config without moving flags into the config file.","solutions":["Name the database on the command so exactly one target is selected","Move the module-specific settings into the per-module section of spacetime.json instead of CLI flags","Remove the offending flags for multi-target runs"],"exampleFix":"# before\nspacetime publish --some-module-only-flag\n# with 2+ publish targets in spacetime.json\n\n# after\nspacetime publish my-db --some-module-only-flag\n# or move the option into that module's spacetime.json entry","handlingStrategy":"validation","validationCode":"// before invoking a multi-target operation, assert no module-specific flags are set\nif targets.len() > 1 {\n    let flags = cfg.module_specific_cli_flags(cmd, matches);\n    assert!(flags.is_empty(), \"module-specific flags {:?} need a single target\", flags);\n}","typeGuard":null,"tryCatchPattern":"Treat the 'Cannot use module-specific arguments' bail as a usage error: parse the flag list from the message, print the resolution hint, and re-run scoped to one database.","preventionTips":["Scope per-module options inside spacetime.json, not on the CLI","Name the target database explicitly in scripts that may run against multi-target configs"],"tags":["cli","multi-target","arguments","spacetime-json","publish"],"backgroundTag":"ambiguous-cli-target","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"}