OpenBB-finance/OpenBB · error · OpenBBError

Error serializing output for an extension-modified endpoint

Error message

Error serializing output for an extension-modified endpoint {path}: {exc}

What it means

Raised in the CPI fetcher's `transform_data` when the IMF API responded but contained no observation rows (`row_data` empty). Unlike the validator errors, this happens after a successful network round-trip: the query was syntactically valid but the IMF SDMX endpoint returned no data points. Wrapped in `OpenBBError`, so it surfaces as a hard error rather than an empty-data signal.

Source

Thrown at openbb_platform/core/openbb_core/api/router/commands.py:333

                        exclude_unset=True, exclude_none=True
                    ).get("results", [])

                    return JSONResponse(
                        content=jsonable_encoder(content), status_code=200
                    )

                if (mutated_output and isinstance(output, OBBject)) or (
                    isinstance(output, OBBject) and no_validate
                ):
                    output.results = output.model_dump(
                        exclude_unset=True, exclude_none=True
                    ).get("results")

                    return JSONResponse(
                        content=jsonable_encoder(output), status_code=200
                    )
            except Exception as exc:  # pylint: disable=W0703
                raise OpenBBError(
                    f"Error serializing output for an extension-modified endpoint {path}: {exc}",
                ) from exc

            if not no_validate:
                return validate_output(output)

        return output

    return wrapper


def add_command_map(command_runner: CommandRunner, api_router: APIRouter) -> None:
    """Add command map to the API router."""
    plugins_router = RouterLoader.from_extensions()

    for route in plugins_router.api_router.routes:
        route.endpoint = build_api_wrapper(command_runner=command_runner, route=route)  # type: ignore # noqa
    api_router.include_router(router=plugins_router.api_router)

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Widen or shift the date range to the country's actual publication window (CPI data typically starts mid-20th century).
  2. Try the alternate index type — some countries publish HICP only (or CPI only).
  3. Retry once after a short delay to rule out a transient empty IMF response.
  4. Catch `OpenBBError` and check for 'No data returned' if your pipeline should degrade to empty instead of failing.

Example fix

# before
res = obb.economy.cpi(provider='imf', country='USA', start_date='1900-01-01', end_date='1910-01-01')

# after
res = obb.economy.cpi(provider='imf', country='USA', start_date='2000-01-01', end_date='2024-12-31')
Defensive patterns

Strategy: try-catch

Try / catch

from openbb_core.app.model.abstract.error import OpenBBError

try:
    res = obb.economy.cpi(provider='imf', country=c, expenditure=exp, start_date=sd, end_date=ed)
except OpenBBError as e:
    if 'No data returned' in str(e):
        res = None  # coverage gap or empty IMF response; widen dates or try alternate index type
    else:
        raise

Prevention

When it happens

Trigger: Requesting a date range entirely outside the country's CPI coverage (e.g. `start_date='1900-01-01'` where data starts in 1960); a country/indicator combination that exists in the mapping but has no published observations; IMF returning an empty dataset during publication lag for the current period.

Common situations: Very old or very recent date windows; newly added CPI countries with no data yet; IMF API intermittent empty responses; index_type selections (CPI vs HICP) where the country only publishes one of them.

Related errors


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