OpenBB-finance/OpenBB · error · ValueError

{error_msg}

Error message

{error_msg}

What it means

This is a re-raise gate, not a new failure: progressive constraint filtering wraps its logic in 'except (KeyError, ValueError)'. Genuine validation failures ('Invalid value(s) for dimension', 'not compatible with dataflow') are re-raised verbatim; everything else is downgraded to an OpenBBWarning and the code falls back to unfiltered codes. Hitting this error means you are seeing one of the validation ValueErrors (641/643/644) passed through unchanged.

Source

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

                        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,
            )
            for dim_id, codes in dimension_codes.items():
                if dim_id not in fetch_kwargs:
                    # Check if URL would be too long
                    joined_codes = "+".join(codes)
                    if len(joined_codes) > 1500:
                        fetch_kwargs[dim_id] = "*"
                        # Store codes for post-fetch filtering
                        if "_indicator_codes_to_filter" not in fetch_kwargs:
                            fetch_kwargs["_indicator_codes_to_filter"] = set()
                        fetch_kwargs["_indicator_codes_to_filter"].update(codes)
                    else:
                        fetch_kwargs[dim_id] = joined_codes

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Treat this as error 641/643/644 - read the inner message and fix the dimension value or dataflow/table mismatch.
  2. Do not attempt to handle this raise site itself; fix inputs.
  3. If you maintain this code, replace message-string matching with a dedicated exception type to avoid regressions.

Example fix

# maintainer hardening: use a typed exception instead of string matching
# before
if 'Invalid value(s) for dimension' in error_msg or 'not compatible with dataflow' in error_msg:
    raise ValueError(error_msg) from e
# after
class DimensionValidationError(ValueError): ...
# raise DimensionValidationError(...) at the sources; here:
if isinstance(e, DimensionValidationError):
    raise e
Defensive patterns

Strategy: try-catch

Try / catch

try:
    res = obb.economy.imf.fetch(dataset=ds, parameters=params)
except ValueError as e:
    msg = str(e)
    if 'Invalid value(s) for dimension' in msg:
        fix_dimension_value(msg)
    elif 'not compatible with dataflow' in msg:
        fix_table_dataflow_pair(msg)
    else:
        raise

Prevention

When it happens

Trigger: Any of the upstream validation errors (invalid dimension value, incompatible dataflow) raised inside the progressive-filtering try block gets caught here and re-raised with the identical message. The string-matching on error_msg is what decides whether you see an exception or only a warning.

Common situations: Same as errors 641/643/644; additionally, refactoring that changes validation message text would silently convert hard failures into the unfiltered-codes fallback - a known fragility of the string-match design.

Related errors


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