{"record":{"id":"4677917ee4732ad0","repo":"OpenBB-finance/OpenBB","slug":"unknown-error-while-transforming-the-data","errorCode":null,"errorMessage":"Unknown error while transforming the data.","messagePattern":"Unknown error while transforming the data\\.","errorType":"exception","errorClass":"EmptyDataError","httpStatus":null,"severity":"warning","filePath":"openbb_platform/providers/fmp/openbb_fmp/models/revenue_business_line.py","lineNumber":97,"sourceCode":"\n            for business_line, revenue_value in segment.items():\n                if revenue_value is not None:\n                    revenue = int(revenue_value) if revenue_value is not None else None\n                    if revenue is not None:\n                        results.append(\n                            FMPRevenueBusinessLineData.model_validate(\n                                {\n                                    \"period_ending\": period_ending,\n                                    \"fiscal_year\": fiscal_year,\n                                    \"fiscal_period\": fiscal_period,\n                                    \"business_line\": business_line.strip(),\n                                    \"revenue\": revenue,\n                                }\n                            )\n                        )\n\n        if not results:\n            raise EmptyDataError(\"Unknown error while transforming the data.\")\n\n        return sorted(results, key=lambda x: (x.period_ending or \"\", x.revenue or 0))\n","sourceCodeStart":79,"sourceCodeEnd":100,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/fmp/openbb_fmp/models/revenue_business_line.py#L79-L100","documentation":"Raised by FMPRevenueBusinessLineFetch.transform_data when the API returned rows but none of them produced a valid business-line revenue entry, leaving `results` empty. The loop skips every item because each segment value is None or the segment dict has no business-line keys. It is an EmptyDataError, so the OpenBB router surfaces it as 'no data' rather than a crash.","triggerScenarios":"Calling openbb.economy.revenue_business_line(symbol=...) via FMP where the company's revenue-per-segment endpoint returns periods whose 'data' dict is empty or whose segment values are all null; also when the symbol trades on an exchange where FMP does not provide segment reporting.","commonSituations":"Small/micro-cap or non-US symbols with no segment disclosure in FMP; free-tier API keys that receive the HTTP 200 but with limited historical depth so older periods come back as nulls; querying a period range FMP does not cover for that company.","solutions":["Verify the symbol actually has segment data by hitting FMP's revenue-product-segment endpoint directly in a browser with the same api_key","Try a different provider for the same router endpoint (e.g. openbb.economy.revenue_business_line(..., provider='fmp') vs the default) to confirm it is FMP-specific","Remove date/period filters so the full available history is requested","Check whether the FMP subscription tier includes the revenue segments endpoint (a related premium message would otherwise appear from response_callback)"],"exampleFix":"# before\nres = await obb.economy.revenue_business_line(symbol='TSLA', provider='fmp').await_to_list()\n\n# after - guard against empty segment coverage\nfrom openbb_core.provider.utils.errors import EmptyDataError\ntry:\n    res = await obb.economy.revenue_business_line(symbol='TSLA', provider='fmp').await_to_list()\nexcept EmptyDataError:\n    res = await obb.economy.revenue_business_line(symbol='TSLA', provider='polygon').await_to_list()","handlingStrategy":"try-catch","validationCode":"import requests\nresp = requests.get(f\"https://financialmodelingprep.com/api/v4/revenue-product-segmentation?symbol={symbol}&period=annual&structure=flat&apikey={key}\")\nrows = resp.json()\nhas_segments = bool(rows) and any(any(v is not None for v in r.get('data', {}).values()) for r in rows)","typeGuard":"def has_business_line_rows(data: list[dict]) -> bool:\n    return any(\n        any(v is not None for v in item.get(\"data\", {}).values())\n        for item in data\n    )","tryCatchPattern":"from openbb_core.provider.utils.errors import EmptyDataError\ntry:\n    rows = await obb.economy.revenue_business_line(symbol=symbol, provider='fmp').await_to_list()\nexcept EmptyDataError:\n    rows = []  # or switch provider / skip symbol","preventionTips":["Pre-check the FMP segmentation endpoint for non-null segment values before querying","Build multi-provider fallback chains for segment data","Treat EmptyDataError as expected for symbols without segment disclosure rather than a failure"],"tags":["fmp","revenue","empty-data","segments"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}