OpenBB-finance/OpenBB · error · OpenBBError

ValueError: {ve}. Ensure the data format matches the expecte

Error message

ValueError: {ve}. Ensure the data format matches the expected format.

What it means

Raised by the economic-indicators model validator when a symbol contains '::' but the identifier part (after strip) is empty. The check is `if not identifier` after `parts[1].strip()`, so trailing spaces don't help — 'IFS::' and 'IFS:: ' both fail. Companion error to the missing-separator check one branch above.

Source

Thrown at openbb_platform/core/openbb_core/app/model/obbject.py:275

                df.set_index(index, inplace=True)

            # Drop columns that are all NaN, but don't rearrange columns
            if sort_columns:
                df.sort_index(axis=1, inplace=True)
            df = df.dropna(axis=1, how="all")

            # Sort by specified column
            if sort_by:
                df.sort_values(
                    by=sort_by,
                    ascending=ascending if ascending is not None else True,
                    inplace=True,
                )

        except OpenBBError as e:
            raise e
        except ValueError as ve:
            raise OpenBBError(
                f"ValueError: {ve}. Ensure the data format matches the expected format."
            ) from ve
        except TypeError as te:
            raise OpenBBError(
                f"TypeError: {te}. Check the data types in your results."
            ) from te
        except Exception as ex:
            raise OpenBBError(f"An unexpected error occurred: {ex}") from ex

        return df

    def to_polars(self) -> "PolarsDataFrame":  # type: ignore
        """Convert results field to polars dataframe."""
        try:
            from polars import from_pandas  # type: ignore # pylint: disable=import-outside-toplevel
        except ImportError as exc:
            raise ImportError(
                "Please install polars: `pip install polars pyarrow`  to use this method."

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Fix the source of the empty identifier — check the lookup that produced it.
  2. Filter empty tokens before joining: `[s for s in symbols if s.split('::', 1)[-1].strip()]`.
  3. Validate each token with a `dataflow::non-empty-identifier` regex before the call.

Example fix

# before
indicator = ''  # lookup returned nothing
symbol = f'IFS::{indicator}'

# after
indicator = lookup_indicator() or 'NGDP_XDC'
symbol = f'IFS::{indicator}'
Defensive patterns

Strategy: validation

Validate before calling

def validate_symbol_identifiers(symbol: str) -> str:
    for s in symbol.split(','):
        left, sep, right = s.partition('::')
        if sep and not right.strip():
            raise ValueError(f'Symbol {s!r} has an empty identifier after ::')
    return symbol

symbol = validate_symbol_identifiers(symbol)

Type guard

def symbol_has_identifier(s: str) -> bool:
    left, sep, right = s.strip().partition('::')
    return bool(sep and right.strip())

Prevention

When it happens

Trigger: `symbol='IFS::'` from f-string building where the identifier variable is empty (`f'{dataflow}::{code}'` with code=''), or a malformed user input with a stray '::'. A multi-symbol list fails on the first malformed token.

Common situations: Template/loop code where the code lookup returned nothing and the empty value is silently concatenated; string concatenation bugs dropping the second half; CSV symbol lists with trailing empty fields.

Related errors


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