OpenBB-finance/OpenBB · error · ValueError

No valid values for dimension '{dim_id}' given constraints.

Error message

No valid values for dimension '{dim_id}' given constraints. Table indicator codes: {codes}available for {prior_selections}: {sorted(available_values)}

What it means

Raised when a non-standard-order dimension (not in dims_in_order) has hierarchy codes, none of which appear in the dimension's available options after filtering - i.e. zero intersection between the table's codes and available values under current constraints. The message lists both sets so the user can see there is no overlap.

Source

Thrown at openbb_platform/providers/imf/openbb_imf/utils/table_builder.py:740

                        # Check if URL would be too long
                        joined_codes = "+".join(filtered_codes)
                        if len(joined_codes) > 1500:
                            fetch_kwargs[dim_id] = "*"
                            if "_indicator_codes_to_filter" not in fetch_kwargs:
                                fetch_kwargs["_indicator_codes_to_filter"] = set()
                            fetch_kwargs["_indicator_codes_to_filter"].update(
                                filtered_codes
                            )
                        else:
                            fetch_kwargs[dim_id] = joined_codes
                    else:
                        # No valid codes - this dimension has no data for given constraints
                        prior_selections = {
                            d: fetch_kwargs.get(d) or normalized_kwargs.get(d)
                            for d in dims_in_order
                            if fetch_kwargs.get(d) or normalized_kwargs.get(d)
                        }
                        raise ValueError(
                            f"No valid values for dimension '{dim_id}' given constraints. "
                            f"Table indicator codes: {codes}"
                            f"available for {prior_selections}: {sorted(available_values)}"
                        )

        except (KeyError, ValueError) as e:
            # Check if this is a validation error - don't suppress those
            error_msg = str(e)
            if (
                "Invalid value(s) for dimension" in error_msg
                or "not compatible with dataflow" in error_msg
            ):
                raise ValueError(error_msg) from e
            # Fallback: use all codes if progressive validation fails
            warnings.warn(
                f"Progressive constraint filtering failed: {e}. Using unfiltered codes.",
                OpenBBWarning,
            )

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Relax the constraining earlier selections (usually country) to one where the dimension has data.
  2. Use '*' for the constraining dimension and filter results client-side.
  3. Pick codes from the 'available for ...' list in the error text instead of the table defaults.
  4. Refresh provider caches/metadata if availability appears incorrect.
Defensive patterns

Strategy: validation

Validate before calling

# For auxiliary dimensions, confirm at least one table code is available before fetching
avail = {opt['value'] for opt in builder.get_options_for_dimension(dim_id)}
if not (set(table_codes) & avail):
    widen_constraints()  # e.g. set COUNTRY='*' and filter client-side

Try / catch

try:
    res = obb.economy.imf.fetch(...)
except ValueError as e:
    if 'No valid values for dimension' in str(e):
        params[constraining_dim] = '*'  # retry once with relaxed constraint
        res = obb.economy.imf.fetch(dataset=ds, parameters=params)
    else:
        raise

Prevention

When it happens

Trigger: Fetching a table where an auxiliary dimension (e.g. a counterpart or classification dimension outside the standard order) has codes defined, but every one of them is absent from available options for the current country/table combination; occurs in the post-loop handling of dimension_codes not in dims_in_order.

Common situations: Regional aggregates queried with codes only valid for bilateral data; stale table definitions referencing retired classification codes; tables whose extra dimensions are country-specific.

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/ee34ee9f17196113. Report an issue: GitHub.