OpenBB-finance/OpenBB · error · OpenBBError
Invalid indicator code(s) for dataflow '{dataflow}': {'; '.j
Error message
Invalid indicator code(s) for dataflow '{dataflow}': {'; '.join(error_parts)}. Use `obb.economy.available_indicators(provider='imf', dataflows='{dataflow}')` to see all valid codes. What it means
Raised in helpers.py when building an SDMX dimension filter: one or more indicator codes could not be matched against the dataflow's expected dimension structure. The message dissects each failing code per-segment (which dimension a segment was expected in, with a 5-value sample of valid codes) and points to obb.economy.available_indicators(provider='imf', dataflows=...) to list valid codes. A broad except keeps a fallback (dumping all codes into the INDICATOR dimension) for non-validation failures, so this error means validation ran and positively failed.
Source
Thrown at openbb_platform/providers/imf/openbb_imf/utils/helpers.py:313
else:
expected_pos = idx
if 0 <= expected_pos < len(effective_dim_order):
expected_dim = effective_dim_order[expected_pos]
sample = sorted(
codes_by_dimension.get(expected_dim, set())
)[:5]
segment_errors.append(
f"'{seg}' is invalid for {expected_dim} (valid: {', '.join(sample)})"
)
else:
segment_errors.append(f"'{seg}' is unrecognized")
error_parts.append(f"'{code}': {'; '.join(segment_errors)}")
else:
error_parts.append(f"'{code}'")
raise OpenBBError(
f"Invalid indicator code(s) for dataflow '{dataflow}': "
f"{'; '.join(error_parts)}. "
f"Use `obb.economy.available_indicators(provider='imf', dataflows='{dataflow}')` to see all valid codes."
)
except OpenBBError:
raise
except Exception:
# Fallback: put all codes in INDICATOR dimension (can't validate)
dimension_codes["INDICATOR"] = indicator_codes
return dict(dimension_codes)
def detect_transform_dimension(
dataflow: str,
) -> tuple[str | None, str | None, dict[str, str], dict[str, str]]:
"""View on GitHub (pinned to 3e071fcc2c)
Solutions
- Run obb.economy.available_indicators(provider='imf', dataflows='<your dataflow>') and copy exact codes.
- Read the per-segment detail in the message — it names the expected dimension and 5 valid example values for each bad segment.
- Update the provider package (openbb-imf) if codes were valid before an IMF metadata change: pip install -U openbb-imf.
Example fix
# before res = await obb.economy.gdp(component='nominal', provider='imf') # or direct fetcher with indicator='TXG_FOB_US' # after valid = await obb.economy.available_indicators(provider='imf', dataflows='IMTS') # pick exact code from valid, e.g. 'TXG_FOB_USD' res = imts_query(country='USA', counterpart='*', indicator='TXG_FOB_USD')
Defensive patterns
Strategy: validation
Validate before calling
indicators = await obb.economy.available_indicators(provider='imf', dataflows='IMTS').to_df()
valid_codes = set(indicators['indicator'].astype(str)) if 'indicator' in indicators else set(indicators.iloc[:, 0])
missing = [c for c in my_codes if c not in valid_codes]
if missing:
raise ValueError(f'Unknown indicator codes: {missing}') Try / catch
try:
res = imts_query(country=c, counterpart=cp, indicator=codes)
except OpenBBError as e:
if 'Invalid indicator code' in str(e):
raise ValueError('Check codes via obb.economy.available_indicators(provider="imf").') from e
raise Prevention
- Fetch and cache the available_indicators list per dataflow at startup.
- Never share indicator literals between dataflows.
- Update openbb-imf after IMF metadata revisions.
When it happens
Trigger: Passing indicator codes from a different dataflow (e.g. an IFS code like 'IR3TIB01A' to the DOT/IMTS dataflow); typo'd codes ('TXG_FOB_US' missing 'D'); structural codes whose dimension order/ prefixes changed after an IMF metadata revision.
Common situations: Copy-pasting indicator examples across dataflows; metadata refreshes that rename codes; mixing provider indicator vocabularies (intrinio/fred tickers passed to imf).
Related errors
- Invalid {name}(s): {', '.join(invalid)}
- Dataflow '{dataflow_id}' not found.
- Data structure not found for dataflow '{dataflow_id}'.
- Dataflow '{dataflow_id}' not found. Available dataflows: {li
- Dimension '{dimension_id}' not found for dataflow '{self.dat
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/03cd535b69c0bafe.
Report an issue: GitHub.