{"record":{"id":"00c5890dfdc3d003","repo":"reflex-dev/reflex","slug":"app-name-must-be-provided-when-app-source-is-a-str","errorCode":null,"errorMessage":"app_name must be provided when app_source is a string.","messagePattern":"app_name must be provided when app_source is a string\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"reflex/testing.py","lineNumber":161,"sourceCode":"\n        Returns:\n            AppHarness instance\n\n        Raises:\n            ValueError: when app_source is a string and app_name is not provided.\n        \"\"\"\n        if app_name is None:\n            if app_source is None:\n                app_name = root.name\n            elif isinstance(app_source, functools.partial):\n                keywords = app_source.keywords\n                slug_suffix = \"_\".join([str(v) for v in keywords.values()])\n                func_name = app_source.func.__name__\n                app_name = f\"{func_name}_{slug_suffix}\"\n                app_name = re.sub(r\"[^a-zA-Z0-9_]\", \"_\", app_name)\n            elif isinstance(app_source, str):\n                msg = \"app_name must be provided when app_source is a string.\"\n                raise ValueError(msg)\n            else:\n                app_name = app_source.__name__\n\n            app_name = app_name.lower()\n            while \"__\" in app_name:\n                app_name = app_name.replace(\"__\", \"_\")\n        return cls(\n            app_name=app_name,\n            app_source=app_source,\n            app_path=root,\n            app_module_path=root / app_name / f\"{app_name}.py\",\n        )\n\n    def get_state_name(self, state_cls_name: str) -> str:\n        \"\"\"Get the state name for the given state class name.\n\n        Args:\n            state_cls_name: The state class name","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/testing.py#L143-L179","documentation":"AppHarness.create raises ValueError when app_source is a plain string (a module import path) but no app_name is given. For string sources Reflex cannot reliably derive a unique harness name, so it requires you to supply one explicitly.","triggerScenarios":"Calling AppHarness.create(root=..., app_source=\"my_app.my_app\") without passing app_name. Passing a function or App instance works because the name is derived from the function/module name.","commonSituations":"Writing integration tests against an existing app module path instead of a factory function; converting a function-based fixture to a string-based one and dropping the app_name argument.","solutions":["Pass app_name explicitly: AppHarness.create(root=tmp_path, app_source=\"my_app.my_app\", app_name=\"my_app\")","Prefer passing a factory function as app_source so the name is auto-derived"],"exampleFix":"# before\nwith AppHarness.create(root=tmp, app_source=\"myapp.myapp\") as h:\n\n# after\nwith AppHarness.create(root=tmp, app_source=\"myapp.myapp\", app_name=\"myapp\") as h:","handlingStrategy":"validation","validationCode":"if isinstance(app_source, str) and not app_name:\n    app_name = app_source.rsplit(\".\", 1)[-1]  # derive a fallback name\nwith AppHarness.create(root=tmp, app_source=app_source, app_name=app_name) as h:\n    ...","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass app_name alongside string app_source","Prefer factory functions as app_source so names are derived automatically"],"tags":["reflex","testing","app-harness","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}