{"record":{"id":"ab97026fa7544044","repo":"clockworklabs/SpacetimeDB","slug":"unreal-module-name-is-required-for-lang-unreal","errorCode":null,"errorMessage":"--unreal-module-name is required for --lang unrealcpp","messagePattern":"--unreal-module-name is required for --lang unrealcpp","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/generate.rs","lineNumber":347,"sourceCode":"        let module_name = command_config.get_one::<String>(\"unreal_module_name\")?;\n        let module_prefix = command_config.get_one::<String>(\"module_prefix\")?;\n        let build_options = command_config\n            .get_one::<String>(\"build_options\")?\n            .unwrap_or_else(String::new);\n        let dotnet_version = if command_config.is_from_cli(\"dotnet_version\") {\n            command_config.get_one::<u8>(\"dotnet_version\")?\n        } else {\n            let dotnet_version = command_config.get_one::<String>(\"dotnet_version\")?;\n            parse_optional_dotnet_version(dotnet_version.as_deref())?\n        };\n\n        // Validate Unreal-specific args first to preserve focused errors for this mode.\n        if requested_lang == Some(Language::UnrealCpp) {\n            if command_config.get_one::<PathBuf>(\"uproject_dir\")?.is_none() {\n                return Err(anyhow::anyhow!(\"--uproject-dir is required for --lang unrealcpp\"));\n            }\n            if module_name.is_none() {\n                return Err(anyhow::anyhow!(\"--unreal-module-name is required for --lang unrealcpp\"));\n            }\n        }\n\n        // Validate module source path for source-based generation.\n        if wasm_file.is_none() && js_file.is_none() && !project_path.is_dir() {\n            anyhow::bail!(\n                \"Could not find module source at '{}'. \\\n                 If this is not correct, pass --module-path or add module-path in spacetime.json. \\\n                 You can also pass --bin-path/--js-path to generate without building from source.\",\n                project_path.display()\n            );\n        }\n\n        let lang = match requested_lang {\n            Some(lang) => lang,\n            None => {\n                let client_project_dir = config_dir.unwrap_or_else(|| Path::new(\".\"));\n                let detected = detect_default_language(client_project_dir)?;","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/cli/src/subcommands/generate.rs#L329-L365","documentation":"Second of the two unrealcpp pre-flight validations in `spacetime generate`: the generated plugin code needs an Unreal module name to emit the correct BUILD.cs and API macros. After confirming --uproject-dir is present, the CLI checks module_name; if it is None (no --unreal-module-name flag, no `module-name` in config), generation stops here.","triggerScenarios":"Running `spacetime generate --lang unrealcpp --uproject-dir <dir>` without `--unreal-module-name` and without a module-name key in the generate config entry. Always fires after the uproject-dir check passes, i.e. you will only see it once error 345 is fixed.","commonSituations":"Iteratively fixing unrealcpp args — adding --uproject-dir then hitting this next; assuming the module name is inferred from the .uproject file (it is not, at this validation point); config entries migrated from csharp generation that use a different key name.","solutions":["Pass the UE module name matching your game module: `--unreal-module-name MyGame`","Or add `\"module-name\": \"MyGame\"` to the unrealcpp generate entry in spacetime.json","Check the name matches a module declared in your .uproject/Source so generated BUILD.cs compiles"],"exampleFix":"# before\nspacetime generate --lang unrealcpp --uproject-dir ~/Projects/MyGame\n# after\nspacetime generate --lang unrealcpp --uproject-dir ~/Projects/MyGame --unreal-module-name MyGame","handlingStrategy":"validation","validationCode":": \"${MODULE_NAME:?--unreal-module-name required for unrealcpp}\"\nspacetime generate --lang unrealcpp --uproject-dir \"$UPROJECT_DIR\" --unreal-module-name \"$MODULE_NAME\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass --unreal-module-name together with --uproject-dir — fix both unreal args in one edit","Match the name to a module under your .uproject's Source/ directory so generated code compiles","Pin both values in spacetime.json to keep CI and local runs identical"],"tags":["cli","generate","unreal","unrealcpp","arguments","validation"],"backgroundTag":"missing-required-argument","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"}