OpenBB-finance/OpenBB · error · AttributeError
Invalid command : route={route}
Error message
Invalid command : route={route} What it means
Raised by the DOT country/counterpart validator when the token list contains more than one entry and any entry (after strip/lower) is 'all' or '*'. The IMF API treats '*' as a standalone wildcard dimension; mixing it with explicit codes is not expressible, so the validator rejects it upfront.
Source
Thrown at openbb_platform/core/openbb_core/app/command_runner.py:454
**kwargs,
) -> OBBject:
"""Run a command and return the OBBject as output."""
timestamp = datetime.now()
start_ns = perf_counter_ns()
command_map = execution_context.command_map
route = execution_context.route
if func := command_map.get_command(route=route):
obbject = await cls._execute_func(
route=route,
args=args, # type: ignore
execution_context=execution_context,
func=func,
kwargs=kwargs,
)
else:
raise AttributeError(f"Invalid command : route={route}")
duration = perf_counter_ns() - start_ns
if execution_context.user_settings.preferences.metadata and isinstance(
obbject, OBBject
):
try:
obbject.extra["metadata"] = Metadata(
arguments=kwargs,
duration=duration,
route=route,
timestamp=timestamp,
)
except Exception as e:
if Env().DEBUG_MODE:
raise OpenBBError(e) from e
warn(str(e), OpenBBWarning)
View on GitHub (pinned to 3e071fcc2c)
Solutions
- Use either a wildcard alone (`country='all'`) or explicit codes only (`country='USA,DEU'`) — never both.
- In dynamic list building, drop 'all'/'*' tokens whenever the list has other entries (or short-circuit to just 'all').
- Normalize case and whitespace before joining; the validator strips tokens, but your builder may not.
Example fix
# before
codes = ['USA', 'DEU']
codes.append('all')
res = obb.economy.direction_of_trade(provider='imf', country=','.join(codes), counterpart='W00')
# after
codes = ['USA', 'DEU']
res = obb.economy.direction_of_trade(provider='imf', country=','.join(codes), counterpart='W00') Defensive patterns
Strategy: validation
Validate before calling
def normalize_dot_codes(codes: list[str]) -> str:
stripped = [c.strip() for c in codes if c.strip()]
if not stripped:
raise ValueError('At least one country/counterpart code is required.')
if any(c.lower() in ('all', '*') for c in stripped):
if len(stripped) > 1:
raise ValueError("'all'/'*' must be used alone, not mixed with explicit codes.")
return '*'
return ','.join(stripped)
country = normalize_dot_codes(['USA', 'DEU']) Type guard
def is_clean_code_list(codes: list[str]) -> bool:
s = [c.strip() for c in codes if c.strip()]
wildcards = [c for c in s if c.lower() in ('all', '*')]
return not wildcards or len(s) == 1 Prevention
- Never build code lists by appending 'all' — short-circuit to 'all' alone when a wildcard is wanted.
- In multi-select UIs, clear other selections when the user picks 'All'.
When it happens
Trigger: `country='USA,all'`, `counterpart='*,DEU'`, or appending 'all' to a code list dynamically, e.g. `','.join(codes + ['all'])` when codes is non-empty. A single 'all' or '*' alone is fine.
Common situations: UIs that add a default 'All' option to a multi-select that already has selections; string-building code that always appends a wildcard 'for completeness'; copy-pasting a defaults string that includes 'all' plus explicit codes.
Related errors
- Charting is not installed. Please install `openbb-charting`.
- At least one extension type must be selected.
- Incorrect email or password
- OBBject Extension Error -> An OBBject extension that modif
- Results not found.
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/eab0d3d17dbff396.
Report an issue: GitHub.