{"record":{"id":"348e872e81f13ab7","repo":"OpenBB-finance/OpenBB","slug":"error-the-factory-function-name-must-be-provided-348e87","errorCode":null,"errorMessage":"Error: The factory function name must be provided to the --name parameter when the factory flag is set.","messagePattern":"Error: The factory function name must be provided to the --name parameter when the factory flag is set\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/extensions/platform_api/openbb_platform_api/utils/api.py","lineNumber":351,"sourceCode":"                    _kwargs[key] = value.lower() == \"true\"\n                elif key == \"exclude\":\n                    _kwargs[key] = json.loads(value)\n                else:\n                    _kwargs[key] = value\n            else:\n                _kwargs[key] = True\n\n    if _kwargs.get(\"app\"):\n        _app_path = _kwargs.pop(\"app\", None)\n        _name = _kwargs.pop(\"name\", \"app\")\n        _factory = _kwargs.pop(\"factory\", False)\n\n        if \":\" in _app_path:\n            _app_instance_name = _app_path.split(\":\")[-1]\n            _name = _app_instance_name if _app_instance_name else _name\n\n        if _factory and not _name:\n            raise ValueError(\n                \"Error: The factory function name must be provided to the --name parameter when the factory flag is set.\"\n            )\n        _kwargs[\"app\"] = import_app(_app_path, _name, _factory)\n\n    if isinstance(_kwargs.get(\"exclude\"), str):\n        _kwargs[\"exclude\"] = [_kwargs[\"exclude\"]]\n\n    if _kwargs.get(\"agents-json\") or _kwargs.get(\"copilots-path\"):\n        _agents_path = _kwargs.pop(\"agents-json\", None) or _kwargs.pop(\n            \"copilots-path\", None\n        )\n\n        if not str(_agents_path).endswith(\".json\"):\n            _agents_path = (\n                f\"{_agents_path}{'' if _agents_path.endswith('/') else '/'}agents.json\"\n            )\n\n        if str(_agents_path).startswith(\"./\"):","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/extensions/platform_api/openbb_platform_api/utils/api.py#L333-L369","documentation":"Raised in the CLI kwarg-parsing layer when the --factory flag is set but no factory function name resolves from --name or the colon notation. The code requires a concrete name to look up when factory mode is requested.","triggerScenarios":"Invoking the platform API CLI with --factory while --name is empty and --app has no ':name' suffix; note _name defaults to 'app', so this fires mainly when the colon suffix is present but empty (e.g. 'main.py:').","commonSituations":"Typing '--app main.py:' with a trailing colon; shell quoting that strips the name; scripts composing the app string programmatically leaving an empty suffix.","solutions":["Remove the trailing colon or supply the name: --app main.py --name create_app --factory.","Use full colon notation: --app main:create_app --factory.","If not using a factory, drop --factory entirely.","Log the assembled _app_path string before launch to catch empty suffixes."],"exampleFix":"# before\n--app 'main.py:' --factory\n\n# after\n--app 'main.py:create_app' --factory","handlingStrategy":"validation","validationCode":"assert not (factory and not name), \"--factory requires --name or 'path:name' notation\"\nif app_path.endswith(\":\"):\n    raise ValueError(\"empty name after colon in app path\")","typeGuard":"def factory_args_valid(app_path: str, name, factory: bool) -> bool:\n    if not factory:\n        return True\n    suffix = app_path.rsplit(\":\", 1)[-1] if \":\" in app_path else None\n    return bool(name or suffix)","tryCatchPattern":"try:\n    _kwargs[\"app\"] = import_app(_app_path, _name, _factory)\nexcept ValueError as e:\n    if \"factory function name\" in str(e):\n        raise SystemExit(\"pass --name create_app alongside --factory, or use 'main:create_app'\") from e\n    raise","preventionTips":["Never leave a trailing colon in --app","Always pair --factory with --name or full colon notation","Validate assembled CLI strings in a unit test"],"tags":["cli","fastapi","factory","arguments"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}