{"record":{"id":"534fd6fc863b2b47","repo":"clockworklabs/SpacetimeDB","slug":"namespace-is-only-supported-with-lang-csharp","errorCode":null,"errorMessage":"--namespace is only supported with --lang csharp","messagePattern":"--namespace is only supported with --lang csharp","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/generate.rs","lineNumber":485,"sourceCode":"    entry\n}\n\npub async fn run_prepared_generate_configs(\n    run_configs: Vec<GenerateRunConfig>,\n    extract_descriptions: ExtractDescriptions,\n    json_module: Option<Vec<PathBuf>>,\n    force: bool,\n    namespace_from_cli: bool,\n) -> anyhow::Result<()> {\n    for run in run_configs {\n        println!(\n            \"Generating {} module bindings for module {}\",\n            run.lang.display_name(),\n            run.project_path.display()\n        );\n\n        if namespace_from_cli && run.lang != Language::Csharp {\n            return Err(anyhow::anyhow!(\"--namespace is only supported with --lang csharp\"));\n        }\n\n        let module: ModuleDef = if let Some(paths) = &json_module {\n            let DeserializeWrapper::<RawModuleDef>(module) = if let Some(path) = paths.first() {\n                serde_json::from_slice(&fs::read(path)?)?\n            } else {\n                serde_json::from_reader(std::io::stdin().lock())?\n            };\n            module.try_into()?\n        } else {\n            let path = if let Some(path) = &run.wasm_file {\n                println!(\"Skipping build. Instead we are inspecting {}\", path.display());\n                path.clone()\n            } else if let Some(path) = &run.js_file {\n                println!(\"Skipping build. Instead we are inspecting {}\", path.display());\n                path.clone()\n            } else {\n                let (path, _) =","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/cli/src/subcommands/generate.rs#L467-L503","documentation":"`--namespace` on `spacetime generate` maps to the C# namespace used by generated module bindings. Only the C# generator consumes it, so the CLI validates namespace_from_cli && run.lang != Csharp and rejects the combination for Rust, TypeScript, and UnrealCpp. The check is per-run, so it also fires when a spacetime.json file contains multiple generate entries and --namespace was given on the command line even if one entry IS csharp.","triggerScenarios":"Passing `--namespace Foo` together with `--lang rust|typescript|unrealcpp`; or running `spacetime generate --namespace Foo` in a multi-language project where any generate entry (e.g. the TypeScript one) is not csharp. The CLI-level namespace flag applies to every selected run, and any non-csharp run trips the error.","commonSituations":"Copying a csharp invocation while prototyping in TypeScript; multi-target generate configs (csharp + ts) where a global --namespace was intended only for the csharp leg; upgrading older CLI versions that silently ignored --namespace for other languages.","solutions":["Remove --namespace from the command when generating non-csharp bindings","Scope the namespace to config only: set `namespace` inside the csharp generate entry in spacetime.json instead of on the CLI","For mixed projects, run generate twice — once per language — with --namespace only on the csharp invocation"],"exampleFix":"# before\nspacetime generate --lang typescript --namespace MyCompany.MyGame\n# after\nspacetime generate --lang typescript\n\n# csharp keeps it:\nspacetime generate --lang csharp --namespace MyCompany.MyGame","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nlang=\"${1:?}\"; shift\nif [ \"$1\" = \"--namespace\" ] && [ \"$lang\" != \"csharp\" ]; then\n  echo \"--namespace is csharp-only\" >&2; exit 2\nfi\nspacetime generate --lang \"$lang\" \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reserve --namespace for csharp invocations only","In multi-language configs, put namespace inside the csharp generate entry in spacetime.json, not on the CLI","Run generate per language when configs mix csharp with other targets"],"tags":["cli","generate","namespace","csharp","arguments","validation"],"backgroundTag":"invalid-argument-combination","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"}