{"record":{"id":"3946c584d6c0f4d1","repo":"reflex-dev/reflex","slug":"only-template-name-should-be-provided-got-tem","errorCode":null,"errorMessage":"Only {template_name=} should be provided, got {template_code_dir_name=}, {template_dir=}.","messagePattern":"Only (.+?) should be provided, got (.+?), (.+?)\\.","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"reflex/utils/templates.py","lineNumber":66,"sourceCode":"\n    Args:\n        app_name: The name of the app.\n        template_name: The name of the template to use.\n        template_code_dir_name: The name of the code directory in the template.\n        template_dir: The directory of the template source files.\n\n    Raises:\n        SystemExit: If template_name, template_code_dir_name, template_dir combination is not supported.\n    \"\"\"\n    logger.info(\"Initializing the app directory.\")\n\n    # By default, use the blank template from local assets.\n    if template_name == constants.Templates.DEFAULT:\n        if template_code_dir_name is not None or template_dir is not None:\n            logger.error(\n                f\"Only {template_name=} should be provided, got {template_code_dir_name=}, {template_dir=}.\"\n            )\n            raise SystemExit(1)\n        template_code_dir_name = constants.Templates.Dirs.CODE\n        template_dir = Path(constants.Templates.Dirs.BASE, \"apps\", template_name)\n    else:\n        if template_code_dir_name is None or template_dir is None:\n            logger.error(\n                f\"For `{template_name}` template, `template_code_dir_name` and `template_dir` should both be provided.\"\n            )\n            raise SystemExit(1)\n\n    logger.debug(f\"Using {template_name=} {template_dir=} {template_code_dir_name=}.\")\n\n    # Remove __pycache__ dirs in template directory and current directory.\n    for pycache_dir in [\n        *template_dir.glob(\"**/__pycache__\"),\n        *Path.cwd().glob(\"**/__pycache__\"),\n    ]:\n        shutil.rmtree(pycache_dir, ignore_errors=True)\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/utils/templates.py#L48-L84","documentation":"Raised by `reflex.utils.templates.initialize_app_directory` when the default template is selected but extra template location arguments are also supplied. The DEFAULT template is bundled in local Reflex assets, so template_code_dir_name/template_dir are hard-coded internally; providing them indicates the caller misunderstood the API.","triggerScenarios":"Calling initialize_app_directory(template_name=constants.Templates.DEFAULT ('default'), ...) with a non-None template_code_dir_name or template_dir. Typically reached via initialize_default_app or create_config_init_app_from_remote_template wiring arguments incorrectly.","commonSituations":"Custom scaffolding code that always passes template_dir regardless of template name; copy-pasted calls from remote-template code paths into default-template paths.","solutions":["Drop template_code_dir_name and template_dir arguments when using the default template; Reflex fills them from bundled assets.","If you intended a custom/remote template, pass a non-default template_name along with both template_code_dir_name and template_dir."],"exampleFix":"# before\ninitialize_app_directory(\n    template_name=constants.Templates.DEFAULT,\n    template_dir=Path(\"./my_template\"),\n    template_code_dir_name=\"code\",\n)\n\n# after\ninitialize_app_directory(template_name=constants.Templates.DEFAULT)","handlingStrategy":"validation","validationCode":"from reflex import constants\n\ndef validate_template_args(name, code_dir_name, template_dir):\n    if name == constants.Templates.DEFAULT:\n        assert code_dir_name is None and template_dir is None\n    else:\n        assert code_dir_name is not None and template_dir is not None","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When using the bundled default template, pass only template_name.","Reserve template_dir/template_code_dir_name for custom or remote templates."],"tags":["reflex","templates","init","argument-validation"],"backgroundTag":"invalid-argument-combination","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}