{"record":{"id":"99b0c0657598a71a","repo":"clockworklabs/SpacetimeDB","slug":"cannot-use-generate-entry-specific-arguments","errorCode":null,"errorMessage":"Cannot use generate-entry-specific arguments ({}) when generating for multiple entries. Specify a database name to select a single target, or remove these arguments.","messagePattern":"Cannot use generate-entry-specific arguments \\((.+?)\\) when generating for multiple entries\\. Specify a database name to select a single target, or remove these arguments\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/spacetime_config.rs","lineNumber":549,"sourceCode":"    }\n\n    /// Validate that generate-entry-specific CLI flags are not used when operating on multiple generate entries.\n    pub fn validate_no_generate_entry_specific_cli_args(\n        &self,\n        command: &Command,\n        matches: &ArgMatches,\n        entry_count: usize,\n    ) -> anyhow::Result<()> {\n        if entry_count <= 1 {\n            return Ok(());\n        }\n\n        let display_args = self.generate_entry_specific_cli_flags(command, matches);\n        if display_args.is_empty() {\n            return Ok(());\n        }\n\n        anyhow::bail!(\n            \"Cannot use generate-entry-specific arguments ({}) when generating for multiple entries. \\\n             Specify a database name to select a single target, or remove these arguments.\",\n            display_args.join(\", \"),\n        );\n    }\n\n    /// Get the clap argument name for a config key.\n    pub fn clap_arg_name_for<'a>(&'a self, config_name: &'a str) -> &'a str {\n        self.config_to_clap\n            .get(config_name)\n            .map(|s| s.as_str())\n            .unwrap_or(config_name)\n    }\n}\n\n/// Configuration for a single key in the CommandConfig.\n#[derive(Debug, Clone)]\npub struct Key {","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/spacetime_config.rs#L531-L567","documentation":"The generate command's counterpart of the module-arg guard: when generating for multiple entries (entry_count > 1), CLI flags flagged generate_entry_specific are rejected because they could only apply to one entry. The message offers the two escapes: select a single entry by database name, or drop the flags and configure the entries in the config file.","triggerScenarios":"`spacetime generate` in a project whose config declares multiple generate entries, while passing entry-specific CLI options (collected via generate_entry_specific_cli_flags), without a --database selector.","commonSituations":"Adding a second client/database to a project and reusing the previous generate invocation; CI codegen steps that pinned output options per entry via flags.","solutions":["Pass the database name to generate for exactly one entry","Drop the entry-specific flags for multi-entry generation","Encode per-entry options in the spacetime.json generate entries so the CLI stays generic"],"exampleFix":"# before (multiple generate entries in config)\nspacetime generate --out-dir src/generated\n\n# after\nspacetime generate --database mydb --out-dir src/generated","handlingStrategy":"validation","validationCode":"# In codegen scripts, require a database selector once the config has multiple entries\nENTRY_COUNT=$(jq '[.databases[]? | select(.generate)] | length // (.generate_entries // [] | length)' spacetime.json 2>/dev/null || echo 0)\nif [ \"$ENTRY_COUNT\" -gt 1 ] && [ -z \"$DB\" ]; then\n  echo 'pass --database when generating for multiple entries' >&2; exit 2\nfi\nspacetime generate ${DB:+--database \"$DB\"}","typeGuard":null,"tryCatchPattern":"if ! spacetime generate $FLAGS; then\n  # if stderr contains 'generate-entry-specific arguments', retry without entry flags or with --database\n  spacetime generate --database \"$DB\"\nfi","preventionTips":["Treat `spacetime generate` as per-entry: always pass --database in projects with more than one generate entry","Keep entry-specific output options inside each spacetime.json generate entry instead of on the command line"],"tags":["spacetimedb","cli","code-generation","multi-entry","arguments"],"backgroundTag":"ambiguous-target-selection","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}