OpenBB-finance/OpenBB · error · ValueError
Error: The factory function name must be provided to the --n
Error message
Error: The factory function name must be provided to the --name parameter when the factory flag is set.
What it means
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.
Source
Thrown at openbb_platform/extensions/platform_api/openbb_platform_api/utils/api.py:351
_kwargs[key] = value.lower() == "true"
elif key == "exclude":
_kwargs[key] = json.loads(value)
else:
_kwargs[key] = value
else:
_kwargs[key] = True
if _kwargs.get("app"):
_app_path = _kwargs.pop("app", None)
_name = _kwargs.pop("name", "app")
_factory = _kwargs.pop("factory", False)
if ":" in _app_path:
_app_instance_name = _app_path.split(":")[-1]
_name = _app_instance_name if _app_instance_name else _name
if _factory and not _name:
raise ValueError(
"Error: The factory function name must be provided to the --name parameter when the factory flag is set."
)
_kwargs["app"] = import_app(_app_path, _name, _factory)
if isinstance(_kwargs.get("exclude"), str):
_kwargs["exclude"] = [_kwargs["exclude"]]
if _kwargs.get("agents-json") or _kwargs.get("copilots-path"):
_agents_path = _kwargs.pop("agents-json", None) or _kwargs.pop(
"copilots-path", None
)
if not str(_agents_path).endswith(".json"):
_agents_path = (
f"{_agents_path}{'' if _agents_path.endswith('/') else '/'}agents.json"
)
if str(_agents_path).startswith("./"):View on GitHub (pinned to 3e071fcc2c)
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.
Example fix
# before --app 'main.py:' --factory # after --app 'main.py:create_app' --factory
Defensive patterns
Strategy: validation
Validate before calling
assert not (factory and not name), "--factory requires --name or 'path:name' notation"
if app_path.endswith(":"):
raise ValueError("empty name after colon in app path") Type guard
def factory_args_valid(app_path: str, name, factory: bool) -> bool:
if not factory:
return True
suffix = app_path.rsplit(":", 1)[-1] if ":" in app_path else None
return bool(name or suffix) Try / catch
try:
_kwargs["app"] = import_app(_app_path, _name, _factory)
except ValueError as e:
if "factory function name" in str(e):
raise SystemExit("pass --name create_app alongside --factory, or use 'main:create_app'") from e
raise Prevention
- Never leave a trailing colon in --app
- Always pair --factory with --name or full colon notation
- Validate assembled CLI strings in a unit test
When it happens
Trigger: 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:').
Common situations: Typing '--app main.py:' with a trailing colon; shell quoting that strips the name; scripts composing the app string programmatically leaving an empty suffix.
Related errors
- Error: The {name} instance in '{app_path}' appears not to be
- Error: The {name} instance in '{app_path}' is not an instanc
- Error: The factory function name must be provided to the --n
- Failed to load the file specs for '{file_path}'
- Error: Neither module '{module_path}' could be imported nor
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/348e872e81f13ab7.
Report an issue: GitHub.