OpenBB-finance/OpenBB · error · OpenBBError
A query must be provided when no dataflows and keywords are
Error message
A query must be provided when no dataflows and keywords are specified.
What it means
Raised by search_indicators when the dataflows argument is empty AND both query and keywords are also empty. Searching indicators across every dataflow is expensive, so the API refuses to scan all dataflows with no filter — you must narrow either by target dataflow(s) or by a query/keyword. This is a guard against accidental full-catalog scans, not a data problem.
Source
Thrown at openbb_platform/providers/imf/openbb_imf/utils/metadata.py:214
dataflows will be searched, which can be slow.
keywords : list[str] | None, optional
List of keywords to filter results. Each keyword is a single word that must
appear in the indicator's label or description. Keywords prefixed with "not "
will exclude indicators containing that word (e.g., "not USD" excludes indicators
with "USD" in them).
Returns
-------
list[dict]
A list of matching indicators with table/hierarchy information included.
"""
target_dataflow_ids: list = []
if dataflows:
target_dataflow_ids = (
[dataflows] if isinstance(dataflows, str) else dataflows
)
else:
if not query and not keywords:
raise OpenBBError(
"A query must be provided when no dataflows and keywords are specified."
)
target_dataflow_ids = list(self.dataflows.keys())
if not target_dataflow_ids:
raise OpenBBError(
"No valid dataflows found to search indicators in."
"This might be due to incorrect dataflow IDs."
)
# Build a map of indicators to their tables for enrichment
indicator_to_tables: dict[str, list[dict]] = {}
# Also build searchable text for each indicator from their tables
indicator_table_text: dict[str, str] = {}
for df_id in set(target_dataflow_ids):
try:
hierarchies = self.get_dataflow_hierarchies(df_id)View on GitHub (pinned to 3e071fcc2c)
Solutions
- Pass at least one of: dataflows='IMTS', a query string, or keywords.
- If you truly want to browse, first list dataflows (search_dataflows or the dataflows dict) and then search indicators per dataflow.
- Default empty form submissions to a helpful message instead of calling the API.
Example fix
# before res = meta.search_indicators() # nothing supplied # after res = meta.search_indicators(dataflows='IMTS') # or res = meta.search_indicators(query='exports')
Defensive patterns
Strategy: validation
Validate before calling
if not (dataflows or query or keywords):
dataflows = 'IMTS' # or raise: 'narrow your search'
results = meta.search_indicators(dataflows=dataflows, query=query, keywords=keywords) Type guard
def has_search_filter(dataflows, query, keywords) -> bool:
def truthy(v):
return bool(v) and (not isinstance(v, (str, list)) or len(v) > 0)
return truthy(dataflows) or truthy(query) or truthy(keywords) Try / catch
try:
res = meta.search_indicators(**filters)
except OpenBBError as e:
if 'A query must be provided' in str(e):
raise ValueError('Enter a search term or pick a dataflow.') from e
raise Prevention
- Make at least one filter mandatory in UIs wrapping this search.
- Use search_dataflows first for browsing, then search_indicators per dataflow.
- Reject empty form submissions client-side.
When it happens
Trigger: search_indicators() with no arguments; all three filter variables left as None/'' by wrapper code that conditionally sets them.
Common situations: Optional search boxes in UIs where the user hits submit without typing anything; exploratory scripts calling the endpoint 'just to see what's there'.
Related errors
- Query string is empty or invalid -> '{query}'
- No valid dataflows found to search indicators in.This might
- Invalid {name}(s): {', '.join(invalid)}
- Invalid indicator code(s) for dataflow '{dataflow}': {'; '.j
- Dataflow '{dataflow_id}' not found.
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/9dc5fdb05a5163a7.
Report an issue: GitHub.