{"record":{"id":"c7a9187449b58d90","repo":"OpenBB-finance/OpenBB","slug":"the-request-was-returned-empty-c7a918","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/fred/openbb_fred/models/commercial_paper.py","lineNumber":339,"sourceCode":"            raise e from e\n\n        return {\n            \"metadata\": response.metadata,\n            \"data\": [d.model_dump() for d in response.result],\n        }\n\n    @staticmethod\n    def transform_data(\n        query: FREDCommercialPaperParams,\n        data: dict,\n        **kwargs: Any,\n    ) -> list[FREDCommercialPaperData]:\n        \"\"\"Transform data.\"\"\"\n        # pylint: disable=import-outside-toplevel\n        from pandas import Categorical, DataFrame\n\n        if not data:\n            raise EmptyDataError(\"The request was returned empty.\")\n        df = DataFrame(data[\"data\"])\n        metadata = data.get(\"metadata\", {})\n        # Flatten data\n        df = df.melt(id_vars=\"date\", var_name=\"symbol\", value_name=\"value\").query(\n            \"value.notnull()\"\n        )\n        df = df.rename(columns={\"value\": \"rate\"}).sort_values(by=\"date\")\n        # Normalize percent values\n        df[\"rate\"] = df[\"rate\"].astype(float) / 100\n        # Add asset type, maturity, and title\n        df[\"asset_type\"] = df[\"symbol\"].apply(lambda x: CP_SERIES_IDS[x][\"asset\"])\n        df[\"title\"] = df[\"symbol\"].apply(lambda x: CP_SERIES_IDS[x][\"title\"])\n        df[\"maturity\"] = df[\"symbol\"].apply(lambda x: CP_SERIES_IDS[x][\"maturity\"])\n        # Categorize and order.\n        asset_type_categories = [\"asset_backed\", \"financial\", \"nonfinancial\", \"a2p2\"]\n        maturity_categories = [\n            \"overnight\",\n            \"day_7\",","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/fred/openbb_fred/models/commercial_paper.py#L321-L357","documentation":"Raised by FREDCommercialPaperFetch.transform_data when the fetched payload dict is falsy - the FRED series request backing commercial paper rates (CP_SERIES_IDS symbols) returned nothing before the melt/rename pipeline could run. Note the transform then indexes CP_SERIES_IDS by each symbol, so any non-empty but partial payload would instead KeyError.","triggerScenarios":"FRED returning {} for the commercial paper series request - invalid/expired FRED API key producing an empty structure, or a complete failure of the underlying multi-series fetch with no observations for the date window.","commonSituations":"Misconfigured FRED_API_KEY (empty-key requests can yield empty bodies rather than explicit errors); date windows outside the CP series' coverage (some tenors were discontinued in 2020); FRED request throttling.","solutions":["Verify the FRED API key is set and valid (test against fred.stlouisfed.org with a simple series like DFF)","Remove date filters to request full series history","Check which CP series in CP_SERIES_IDS are still published on FRED and whether your window predates/postdates them","Retry after a minute if FRED throttled the request"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import os, requests\nkey = os.environ.get('FRED_API_KEY')\nassert key, 'FRED_API_KEY not set'\nr = requests.get(f'https://api.stlouisfed.org/fred/series/observations?series_id=CPFF&api_key={key}&file_type=json')\nassert r.status_code == 200 and r.json().get('observations'), 'FRED key or series invalid'","typeGuard":"def is_non_empty_payload(payload: object) -> bool:\n    return isinstance(payload, dict) and len(payload) > 0","tryCatchPattern":"from openbb_core.provider.utils.errors import EmptyDataError\ntry:\n    obs = await obb.fixedincome.commercial_paper(provider='fred', start_date=s, end_date=e).await_to_list()\nexcept EmptyDataError:\n    obs = []","preventionTips":["Validate the FRED API key at startup with a cheap known series","Check which CP series tenors are still published - several were discontinued","Remove date filters on discovery calls to confirm series liveness"],"tags":["fred","commercial-paper","empty-data","api-key"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}