{"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":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/spacetime_config.rs","lineNumber":500,"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":482,"sourceCodeEnd":518,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/spacetime_config.rs#L482-L518","documentation":"SpacetimeConfig's argument validator rejects module-specific CLI flags when the command resolves to more than one module target (target_count > 1). A flag that configures one particular module is meaningless when the operation fans out over several modules, so the error lists the offending flags plus the caller-supplied operation context and resolution hint (typically: name the target or drop the flags).","triggerScenarios":"Running a config-aware command (e.g. publish) in a project whose spacetime.json declares multiple modules/databases, while passing one or more module-specific CLI flags, without naming which database/module to operate on.","commonSituations":"A monorepo spacetime.json grew a second module and an existing CI pipeline still passes the single-module command line; developers copying a working single-module invocation into a multi-module project.","solutions":["Add the database/module name to the command so it selects a single target","Remove the module-specific flags for runs that target all modules","Move per-module settings into the spacetime.json entries instead of passing them on the CLI"],"exampleFix":"# before (two modules in spacetime.json; --features applies to one)\nspacetime publish --features heavy\n\n# after\nspacetime publish my-module --features heavy","handlingStrategy":"validation","validationCode":"# Only pass module flags when a single module is targeted\nDB_COUNT=$(jq '.modules | length' spacetime.json)\nif [ \"$DB_COUNT\" -gt 1 ] && [ -z \"$SPACETIME_DB\" ]; then\n  echo 'multiple modules: set SPACETIME_DB before using module-specific flags' >&2; exit 2\nfi\nspacetime publish ${SPACETIME_DB:+\"$SPACETIME_DB\"} --features \"$FEATURES\"","typeGuard":null,"tryCatchPattern":"let out = Command::new(\"spacetime\").args(args).output()?;\nif !out.status.success() {\n    let msg = String::from_utf8_lossy(&out.stderr);\n    if msg.contains(\"Cannot use module-specific arguments\") {\n        // rerun without the flags, or add an explicit database selector\n    }\n}","preventionTips":["Check `jq '.modules | length' spacetime.json` in CI; if >1, always pass the database name with module-scoped flags","Prefer encoding per-module options in spacetime.json entries over CLI flags for shared pipelines"],"tags":["spacetimedb","cli","multi-module","arguments","config"],"backgroundTag":"ambiguous-target-selection","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}