OpenBB-finance/OpenBB · error · ValueError

Error: Data is a required field.

Error message

Error: Data is a required field.

What it means

create_line_chart in openbb_charting/charts/generic_charts.py requires a data argument; when data is None it raises immediately. Callers hitting this usually reached the function through the auto-chart fallback or charting kwargs where no usable data could be resolved (e.g. OBBject results empty, wrong kwarg name).

Source

Thrown at openbb_platform/obbject_extensions/charting/openbb_charting/charts/generic_charts.py:58

    xtitle: str | None = None,
    y: str | list[str] | None = None,
    ytitle: str | None = None,
    y2: str | list[str] | None = None,
    y2title: str | None = None,
    layout_kwargs: dict | None = None,
    scatter_kwargs: dict | None = None,
    normalize: bool = False,
    returns: bool = False,
    same_axis: bool = False,
    **kwargs,
) -> Union["OpenBBFigure", "Figure"]:
    """Create a line chart."""
    # pylint: disable=import-outside-toplevel
    from pandas import DataFrame, Series, to_datetime  # noqa
    from openbb_charting.core.openbb_figure import OpenBBFigure

    if data is None:
        raise ValueError("Error: Data is a required field.")

    auto_layout = False
    index = (  # type: ignore
        data.index.name
        if isinstance(data, (DataFrame, Series))
        else index if index is not None else x if x is not None else "date"
    )
    df: DataFrame = (basemodel_to_df(convert_to_basemodel(data), index=index)).dropna(
        how="all", axis=1
    )

    if df.index.name is None:
        if "date" in df.columns:
            df.date = df.date.apply(to_datetime)
            df.set_index("date", inplace=True)
        else:
            found_index = False
            for col in df.columns:

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Pass the data explicitly: create_line_chart(data=df)
  2. Ensure the source OBBject has non-None results before charting
  3. Check the current function signature (inspect.signature) for the expected parameter name

Example fix

# before
fig = charting.create_line_chart(df=my_df)

# after
fig = charting.create_line_chart(data=my_df)
Defensive patterns

Strategy: validation

Validate before calling

assert data is not None, 'create_line_chart requires data'

Type guard

def has_chart_data(data) -> bool:
    return data is not None and len(data) > 0 if hasattr(data, '__len__') else data is not None

Try / catch

try:
    fig = create_line_chart(data=data)
except ValueError as e:
    if 'Data is a required field' in str(e):
        fig = create_line_chart(data=res.to_df())

Prevention

When it happens

Trigger: Calling create_line_chart() with no data positional/keyword; passing data=None explicitly; auto-chart fallback invoked when obbject.results is None.

Common situations: Kwarg typos like dataset= or df= instead of data=; endpoints returning None results that then trigger the generic chart path; scripting against the internal API signature after it changed.

Related errors


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