OpenBB-finance/OpenBB · error · ValueError
Invalid parse_as value. Must be one of 'table', 'chart', or
Error message
Invalid parse_as value. Must be one of 'table', 'chart', or 'text'.
What it means
ValueError from the OmniWidgetResponseModel validator: the optional 'parse_as' field was supplied but is not one of the three supported values 'table', 'chart', or 'text'. The check is exact-match against a tuple, so 'Table', 'TABLE ', 'json', or 'dataframe' all fail.
Source
Thrown at openbb_platform/extensions/platform_api/openbb_platform_api/response_models.py:219
@model_validator(mode="after")
@classmethod
def validate_model(cls, values) -> "OmniWidgetResponseModel":
"""Validate the Omni widget content."""
# pylint: disable=import-outside-toplevel
import json # noqa
import re
import pandas as pd
content = getattr(values, "content", None)
if content is None:
raise ValueError("Content cannot be empty.")
parse_as = getattr(values, "parse_as", None)
if parse_as and parse_as not in ("table", "chart", "text"):
raise ValueError(
"Invalid parse_as value. Must be one of 'table', 'chart', or 'text'."
)
# If parameter was supplied, assume the data is formatted correctly.
if content and parse_as:
data_format = {
"data_type": "object",
"parse_as": parse_as,
}
values.data_format = data_format
del values.parse_as
return values
if content.__class__.__name__ == "Figure":
values.parse_as = "chart"
try:
content = content.to_json()View on GitHub (pinned to 3e071fcc2c)
Solutions
- Use exactly one of: parse_as="table", parse_as="chart", or parse_as="text"
- Omit parse_as entirely when you want the model to auto-detect the data format from the content
- Normalize external input before constructing: value.strip().lower(), then check membership in {"table", "chart", "text"}
Example fix
# before OmniWidgetResponseModel(content=data, parse_as="Table") # after OmniWidgetResponseModel(content=data, parse_as="table")
Defensive patterns
Strategy: validation
Validate before calling
VALID = {"table", "chart", "text"}
if parse_as is not None:
parse_as = parse_as.strip().lower()
if parse_as not in VALID:
raise ValueError(f"parse_as must be one of {sorted(VALID)}, got {parse_as!r}")
model = OmniWidgetResponseModel(content=content, parse_as=parse_as) Type guard
def is_valid_parse_as(value: object) -> bool:
return value is None or (
isinstance(value, str) and value.strip().lower() in {"table", "chart", "text"}
) Try / catch
try:
model = OmniWidgetResponseModel(content=data, parse_as=parse_as)
except ValueError as e:
if "Invalid parse_as value" in str(e):
model = OmniWidgetResponseModel(content=data) # let the model auto-detect
else:
raise Prevention
- Normalize external parse_as values with .strip().lower() before use
- Omit parse_as to let the model infer the format from the content
- Pin accepted values in your API contract (enum) so clients cannot send variants
When it happens
Trigger: OmniWidgetResponseModel(content=df, parse_as=" dataframe") or parse_as="json". Any value outside ('table', 'chart', 'text') — including case/whitespace variants, since there is no normalization — raises.
Common situations: Frontends sending uppercase or plural forms ('tables', 'charts'), configs copied from another tool whose format names differ, enum drift if the accepted set changes across versions, trailing whitespace from template-filled config values.
Related errors
- Content cannot be empty.
- Incorrect email or password
- Either 'content' or 'url' must be provided.
- Invalid URL reference provided
- At least one extension type must be selected.
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/9bbe5f8bb7967824.
Report an issue: GitHub.