OpenBB-finance/OpenBB · error · ValueError
Dimension '{dimension_id}' not found for dataflow '{self.dat
Error message
Dimension '{dimension_id}' not found for dataflow '{self.dataflow_id}'. What it means
get_dimension_options raises ValueError when the dimension_id argument (or the auto-derived next dimension) is not among the dataflow's ordered dimensions in ImfParamsBuilder. The key built for the constraints request is dimension-ordered, so an unknown dimension cannot be queried.
Source
Thrown at openbb_platform/providers/imf/openbb_imf/utils/progressive_helper.py:93
) -> list[dict[str, str]]:
"""Get the available options for a given dimension, based on the current selections.
Parameters
----------
dimension_id : str
The ID of the dimension to get options for.
Returns
-------
list[dict]
A list of available options, where each option is a dictionary with
'label' and 'value' keys.
"""
dimension_id = dimension_id or self.get_next_dimension_to_select()
if not dimension_id:
return []
if dimension_id not in self._dimensions:
raise ValueError(
f"Dimension '{dimension_id}' not found for dataflow '{self.dataflow_id}'."
)
key_parts: list = []
for dim in self._dimensions:
if self._selections[dim] is not None:
key_parts.append(self._selections[dim])
else:
# Use wildcard '*' for unselected dimensions instead of empty string
# Empty string creates malformed URLs like '../'
key_parts.append("*")
key = ".".join(key_parts)
constraints = self._builder.metadata.get_available_constraints(
dataflow_id=self.dataflow_id,
key=key,
component_id=dimension_id,
)View on GitHub (pinned to 3e071fcc2c)
Solutions
- Inspect builder._dimensions (or the DSD) for the dataflow and use the exact dimension ID.
- Call get_dimension_options() with no argument to let the builder pick the next dimension automatically.
- Use set_dimension((dim, value)) only with IDs from _dimensions.
Example fix
# before opts = builder.get_dimension_options(dimension_id='COUNTRY') # ValueError on REF_AREA dataflows # after opts = builder.get_dimension_options(dimension_id='REF_AREA') # or: opts = builder.get_dimension_options() # auto-advances
Defensive patterns
Strategy: validation
Validate before calling
def safe_dimension_options(builder, dim_id: str | None):
if dim_id is not None and dim_id not in builder._dimensions:
raise ValueError(f'{dim_id!r} not in {builder._dimensions}')
return builder.get_dimension_options(dim_id) Type guard
def is_valid_dimension(builder, dim_id: str) -> bool:
return dim_id in builder._dimensions Try / catch
try:
options = builder.get_dimension_options(dim_id)
except ValueError as e:
if 'not found for dataflow' in str(e):
dim_id = builder._dimensions[0]
options = builder.get_dimension_options(dim_id)
else:
raise Prevention
- Always source dimension IDs from builder._dimensions or the DSD, never from another dataflow's examples.
- Let get_dimension_options() auto-pick the next dimension when possible.
- Remember IMF SDMX 3.0 renamed several dimensions (COUNTRY -> REF_AREA).
When it happens
Trigger: Calling get_dimension_options('COUNTRY') on a dataflow whose dimensions use different IDs (e.g. 'REF_AREA'), or passing an empty result from get_next_dimension_to_select plus a stale hardcoded dimension name.
Common situations: Copy-pasting dimension names between dataflows (IMF renamed COUNTRY to REF_AREA in several SDMX 3.0 dataflows), or assuming dimension IDs without inspecting the dataflow's DSD.
Related errors
- Invalid {name}(s): {', '.join(invalid)}
- Invalid indicator code(s) for dataflow '{dataflow}': {'; '.j
- Dataflow '{dataflow_id}' not found.
- Data structure not found for dataflow '{dataflow_id}'.
- Dataflow '{dataflow_id}' not found. Available dataflows: {li
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/20491df088017d3a.
Report an issue: GitHub.