{"record":{"id":"2a15cd267b0c15af","repo":"OpenBB-finance/OpenBB","slug":"no-data-was-found-for-query-country","errorCode":null,"errorMessage":"No data was found for, {query.country}.","messagePattern":"No data was found for, (.+?)\\.","errorType":"exception","errorClass":"EmptyDataError","httpStatus":null,"severity":"warning","filePath":"openbb_platform/providers/fred/openbb_fred/models/balance_of_payments.py","lineNumber":109,"sourceCode":"        country = BOP_COUNTRIES.get(query.country) if query.country else \"USA\"\n        query_dict = query.model_dump(exclude_none=True)\n        query_dict[\"symbol\"] = \",\".join(list(get_bop_series(country).values()))\n        fred_query = FredSeriesQueryParams(**query_dict)\n        data = await fred_fetcher.aextract_data(fred_query, credentials)\n        return data\n\n    @staticmethod\n    def transform_data(\n        query: FredBalanceOfPaymentsQueryParams,\n        data: dict,\n        **kwargs: Any,\n    ) -> AnnotatedResult[list[FredBalanceOfPaymentsData]]:\n        \"\"\"Transform data.\"\"\"\n        # pylint: disable=import-outside-toplevel\n        from pandas import DataFrame\n\n        if not data:\n            raise EmptyDataError(f\"No data was found for, {query.country}.\")\n        fred_fetcher = FredSeriesFetcher()\n        country = BOP_COUNTRIES.get(query.country) if query.country else \"USA\"\n        query_dict = query.model_dump(exclude_none=True)\n        query_dict[\"symbol\"] = \",\".join(list(get_bop_series(country).values()))\n        fred_query = FredSeriesQueryParams(**query_dict)\n        data = fred_fetcher.transform_data(fred_query, data)\n        series_ids = get_bop_series(country)\n        col_map = {v: k for k, v in series_ids.items()}\n        result = data.result  # type: ignore\n        df = (\n            DataFrame([d.model_dump() for d in result])\n            .set_index(\"date\")\n            .sort_index(ascending=False)\n        )\n        df = df.rename(columns=col_map)\n        records = df.reset_index().fillna(\"N/A\").replace(\"N/A\", None).to_dict(\"records\")\n\n        return AnnotatedResult(","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/fred/openbb_fred/models/balance_of_payments.py#L91-L127","documentation":"Raised by FredBalanceOfPaymentsFetch.transform_data when the fetched dict is empty for the requested country. The BOP fetcher maps query.country through BOP_COUNTRIES to a set of FRED series IDs; an empty payload means FRED returned no observations for any series of that country.","triggerScenarios":"Passing a country whose BOP series FRED does not carry (the valid set is limited to entries in BOP_COUNTRIES, defaulting to USA), or a date range where that country's quarterly BOP series has no observations.","commonSituations":"Requesting countries outside the supported list; querying very recent quarters before FRED publishes BOP data (multi-quarter lag); date windows falling entirely between quarterly observations.","solutions":["Use a country present in the BOP_COUNTRIES mapping of the module (e.g. 'united_states' or its listed peers) - read the module's constant if unsure","Widen the date range to span several quarters - the data is quarterly with long publication lags","Check the underlying FRED series pages for that country to confirm coverage","Fall back to another provider for balance-of-payments data"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from openbb_fred.models.balance_of_payments import BOP_COUNTRIES\nassert not query.country or query.country in BOP_COUNTRIES, f'use one of {list(BOP_COUNTRIES)}'","typeGuard":"def is_supported_bop_country(country: str | None, supported: dict) -> bool:\n    return country is None or country in supported","tryCatchPattern":"from openbb_core.provider.utils.errors import EmptyDataError\ntry:\n    rows = await obb.economy.balance_of_payments(provider='fred', country=c).await_to_list()\nexcept EmptyDataError:\n    rows = []","preventionTips":["Use only countries listed in the module's BOP_COUNTRIES mapping","Span multiple quarters in date ranges - BOP data is quarterly with long lags","Cache the supported-country list at startup instead of hardcoding"],"tags":["fred","balance-of-payments","country","empty-data"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}