{"record":{"id":"47e0ef97e55b7094","repo":"OpenBB-finance/OpenBB","slug":"error-serializing-output-for-an-extension-modified","errorCode":null,"errorMessage":"Error serializing output for an extension-modified endpoint {path}: {exc}","messagePattern":"Error serializing output for an extension-modified endpoint (.+?): (.+?)","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/core/openbb_core/api/router/commands.py","lineNumber":333,"sourceCode":"                        exclude_unset=True, exclude_none=True\n                    ).get(\"results\", [])\n\n                    return JSONResponse(\n                        content=jsonable_encoder(content), status_code=200\n                    )\n\n                if (mutated_output and isinstance(output, OBBject)) or (\n                    isinstance(output, OBBject) and no_validate\n                ):\n                    output.results = output.model_dump(\n                        exclude_unset=True, exclude_none=True\n                    ).get(\"results\")\n\n                    return JSONResponse(\n                        content=jsonable_encoder(output), status_code=200\n                    )\n            except Exception as exc:  # pylint: disable=W0703\n                raise OpenBBError(\n                    f\"Error serializing output for an extension-modified endpoint {path}: {exc}\",\n                ) from exc\n\n            if not no_validate:\n                return validate_output(output)\n\n        return output\n\n    return wrapper\n\n\ndef add_command_map(command_runner: CommandRunner, api_router: APIRouter) -> None:\n    \"\"\"Add command map to the API router.\"\"\"\n    plugins_router = RouterLoader.from_extensions()\n\n    for route in plugins_router.api_router.routes:\n        route.endpoint = build_api_wrapper(command_runner=command_runner, route=route)  # type: ignore # noqa\n    api_router.include_router(router=plugins_router.api_router)","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/core/openbb_core/api/router/commands.py#L315-L351","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Widen or shift the date range to the country's actual publication window (CPI data typically starts mid-20th century).","Try the alternate index type — some countries publish HICP only (or CPI only).","Retry once after a short delay to rule out a transient empty IMF response.","Catch `OpenBBError` and check for 'No data returned' if your pipeline should degrade to empty instead of failing."],"exampleFix":"# before\nres = obb.economy.cpi(provider='imf', country='USA', start_date='1900-01-01', end_date='1910-01-01')\n\n# after\nres = obb.economy.cpi(provider='imf', country='USA', start_date='2000-01-01', end_date='2024-12-31')","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from openbb_core.app.model.abstract.error import OpenBBError\n\ntry:\n    res = obb.economy.cpi(provider='imf', country=c, expenditure=exp, start_date=sd, end_date=ed)\nexcept OpenBBError as e:\n    if 'No data returned' in str(e):\n        res = None  # coverage gap or empty IMF response; widen dates or try alternate index type\n    else:\n        raise","preventionTips":["Anchor date windows to each country's known CPI publication history rather than fixed global ranges.","In batch pipelines, catch OpenBBError and degrade the country to 'skipped — no data' instead of aborting.","Retry once before concluding coverage is missing; IMF occasionally returns transient empty payloads."],"tags":["imf","openbb","cpi","no-data","date-range","remote-api"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}