{"record":{"id":"893c49c1b8b8ebdd","repo":"OpenBB-finance/OpenBB","slug":"the-request-was-returned-empty-893c49","errorCode":null,"errorMessage":"The request was returned empty.","messagePattern":"The request was returned empty\\.","errorType":"exception","errorClass":"EmptyDataError","httpStatus":null,"severity":"warning","filePath":"openbb_platform/providers/fmp/openbb_fmp/models/yield_curve.py","lineNumber":99,"sourceCode":"            )\n            return url\n\n        dates = query.date.split(\",\")  # type: ignore\n        urls = [generate_url(date) for date in dates]\n\n        return await get_data_urls(urls, **kwargs)  # type: ignore\n\n    @staticmethod\n    def transform_data(\n        query: FMPYieldCurveQueryParams, data: list, **kwargs: Any\n    ) -> list[FMPYieldCurveData]:\n        \"\"\"Return the transformed data.\"\"\"\n        # pylint: disable=import-outside-toplevel\n        from numpy import nan\n        from pandas import Categorical, DataFrame, DatetimeIndex\n\n        if not data:\n            raise EmptyDataError(\"The request was returned empty.\")\n        df = DataFrame(data).set_index(\"date\").sort_index()\n        dates = query.date.split(\",\") if query.date else [df.index.max()]  # type: ignore\n        df.index = DatetimeIndex(df.index)\n        dates_list = DatetimeIndex(dates)\n        df = df.rename(columns=maturity_dict)\n        df.columns.name = \"maturity\"\n\n        # Find the nearest date in the DataFrame to each date in dates_list\n        nearest_dates = [df.index.asof(date) for date in dates_list]\n\n        # Filter for only the nearest dates\n        df = df[df.index.isin(nearest_dates)]\n\n        df = df.replace({nan: None})\n\n        # Flatten the DataFrame\n        flattened_data = df.reset_index().melt(\n            id_vars=\"date\", var_name=\"maturity\", value_name=\"rate\"","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/fmp/openbb_fmp/models/yield_curve.py#L81-L117","documentation":"Raised by FMPYieldCurveFetch.transform_data when the fetched list of treasury yield records is empty, before any pandas processing (pivot to maturities, nearest-date lookup) happens. The FMP treasury-charts endpoint returned no rows for the requested date or date range.","triggerScenarios":"Querying the FMP yield curve for a weekend/holiday date, a date in the future, or a historical date FMP's treasury dataset does not reach; the fetcher builds urls from query.date and get_data_urls merges the results.","commonSituations":"Requesting the latest curve on a non-trading day without a fallback date; passing a single holiday like '2024-12-25'; FMP occasionally returns empty payloads during data pipeline outages.","solutions":["Pass an explicit recent business day (e.g. date='2024-12-24') instead of relying on the default latest date","Check the FMP treasury yield curve endpoint directly to verify coverage for that date","Retry once after a short delay in case of a transient FMP data outage","Use another provider's yield_curve implementation as a fallback"],"exampleFix":"# before\ncurve = await obb.economy.yield_curve(provider='fmp', date='2024-12-25').await_to_list()\n\n# after - use the nearest prior trading day\ncurve = await obb.economy.yield_curve(provider='fmp', date='2024-12-24').await_to_list()","handlingStrategy":"validation","validationCode":"from pandas.tseries.holiday import USFederalHolidayCalendar\nfrom pandas import bdate_range\ncal = USFederalHolidayCalendar()\nholidays = cal.holidays(start='2020-01-01', end='2030-12-31')\ndef is_trading_day(d):\n    return d not in holidays and d.weekday() < 5\nassert is_trading_day(pd.Timestamp(date))","typeGuard":null,"tryCatchPattern":"from openbb_core.provider.utils.errors import EmptyDataError\ntry:\n    curve = await obb.economy.yield_curve(provider='fmp', date=d).await_to_list()\nexcept EmptyDataError:\n    # walk back to the previous business day\ncurve = await obb.economy.yield_curve(provider='fmp', date=prev_bday(d)).await_to_list()","preventionTips":["Convert requested dates to the previous US business day before querying","Default to no explicit date (latest) and only walk back when empty","Cache the last known good curve date"],"tags":["fmp","yield-curve","treasury","empty-data"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}