OpenBB-finance/OpenBB · error · ValueError
Dataflow '{dataflow}' not found.
Error message
Dataflow '{dataflow}' not found. What it means
ImfQueryBuilder.build_url raises ValueError when the requested dataflow is absent from the locally loaded IMF SDMX dataflows metadata. URL construction needs the dataflow's agencyID and structureRef, so it refuses unknown IDs immediately.
Source
Thrown at openbb_platform/providers/imf/openbb_imf/utils/query_builder.py:28
class ImfQueryBuilder:
"""IMF Query Builder for constructing and executing SDMX REST queries."""
def __init__(self):
"""Initialize the query builder with metadata singleton."""
self.metadata = ImfMetadata()
def build_url(
self,
dataflow: str,
start_date: str | None = None,
end_date: str | None = None,
limit: int | None = None,
**kwargs,
) -> str:
"""Build the IMF SDMX REST API URL for data retrieval."""
if dataflow not in self.metadata.dataflows:
raise ValueError(f"Dataflow '{dataflow}' not found.")
df = self.metadata.dataflows[dataflow]
agency_id = df.get("agencyID")
dsd_id = df.get("structureRef", {}).get("id")
if not dsd_id or dsd_id not in self.metadata.datastructures:
raise ValueError(f"Data structure not found for dataflow '{dataflow}'.")
dsd = self.metadata.datastructures[dsd_id]
all_dimensions = dsd.get("dimensions", [])
dimension_ids = {d["id"] for d in all_dimensions if d.get("id")}
# Create a map for case-insensitive matching of dimension IDs
dimension_id_map = {d_id.lower(): d_id for d_id in dimension_ids}
final_kwargs: dict = {}
for key, value in kwargs.items():
# Try to match the key (case-insensitive) to a known dimension IDView on GitHub (pinned to 3e071fcc2c)
Solutions
- List ImfQueryBuilder().metadata.dataflows and use an exact ID.
- Refresh cached IMF metadata (delete the provider's metadata cache) and retry.
- Upgrade openbb-imf to pick up newly added dataflows.
- Confirm the ID on the IMF SDMX data catalog if unsure.
Example fix
# before url = builder.build_url(dataflow='IRFCL') # ValueError if retired/renamed # after ids = list(builder.metadata.dataflows) url = builder.build_url(dataflow=next(i for i in ids if 'IRFCL' in i or i == 'IRFCL'))
Defensive patterns
Strategy: validation
Validate before calling
def assert_dataflow(qb, dataflow: str):
flows = qb.metadata.dataflows
if dataflow not in flows:
raise ValueError(f'Unknown dataflow {dataflow!r}; choose from {sorted(flows)}')
assert_dataflow(ImfQueryBuilder(), 'BOP') Type guard
def is_valid_dataflow(qb, dataflow: str) -> TypeGuard[str]:
return dataflow in qb.metadata.dataflows Try / catch
try:
url = qb.build_url(dataflow, **kwargs)
except ValueError as e:
if 'not found' in str(e):
match = difflib.get_close_matches(dataflow, qb.metadata.dataflows, n=1)
url = qb.build_url(match[0], **kwargs) if match else raise_
else:
raise Prevention
- Look up dataflow IDs from metadata.dataflows rather than documentation snippets.
- Clear the metadata cache after IMF announces registry changes.
- Wrap user-facing inputs with a dataflow validator before calling build_url.
When it happens
Trigger: Calling build_url('XXX') with a nonexistent/retired dataflow ID, or a valid ID while metadata failed to load fully (empty dataflows dict).
Common situations: Typos, retired IMF dataflows, stale metadata cache after IMF restructures its SDMX registry, or an older openbb-imf that predates a new dataflow.
Related errors
- Dataflow '{dataflow_id}' not found. Available dataflows: {li
- Extension '{ext_name}' is not installed.
- 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/db0fc9fdc93c7548.
Report an issue: GitHub.