{"record":{"id":"0a012ab10cc204d2","repo":"OpenBB-finance/OpenBB","slug":"the-request-was-returned-empty-this-may-be-due-to","errorCode":null,"errorMessage":"The request was returned empty. This may be due to an invalid, or incorrectly mapped, portfolio choice.","messagePattern":"The request was returned empty\\. This may be due to an invalid, or incorrectly mapped, portfolio choice\\.","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/famafrench/openbb_famafrench/models/country_portfolio_returns.py","lineNumber":247,"sourceCode":"                ),\n            )\n        except Exception as e:  # pylint: disable=broad-except\n            raise OpenBBError(e) from e\n\n    @staticmethod\n    def transform_data(\n        query: FamaFrenchCountryPortfolioReturnsQueryParams,\n        data: tuple,\n        **kwargs: Any,\n    ) -> AnnotatedResult[list[FamaFrenchCountryPortfolioReturnsData]]:\n        \"\"\"Transform the extracted data.\"\"\"\n        # pylint: disable=import-outside-toplevel\n        from pandas import MultiIndex\n\n        dfs, meta = data\n\n        if not dfs:\n            raise OpenBBError(\n                \"The request was returned empty.\"\n                + \" This may be due to an invalid, or incorrectly mapped, portfolio choice.\"\n            )\n        returns_data = dfs[0] if isinstance(dfs, list) else dfs\n\n        # Values of -99.99  or -999 indicate no data,\n        # Drop columns that have no data.\n        for col in returns_data.columns:\n            if all(returns_data[col].values == \"-99.99\") or all(\n                returns_data[col].values == \"-999\"\n            ):\n                returns_data = returns_data.drop(columns=[col])\n            else:\n                returns_data[col] = (\n                    returns_data[col].astype(int)\n                    if query.measure == \"ratios\" and col == \"firms\"\n                    else returns_data[col].astype(float)\n                )","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/famafrench/openbb_famafrench/models/country_portfolio_returns.py#L229-L265","documentation":"Fama-French country portfolio returns transform guard: extraction returned no DataFrames, and the message points at the usual root cause — a portfolio choice that is invalid or not correctly mapped to a downloadable dataset. The query param for portfolio must correspond to an actual file in the Fama-French library.","triggerScenarios":"Choosing a country/portfolio combination whose returns file does not exist on the Fama-French FTP; a portfolio label that fails the internal mapping to a dataset filename, yielding an empty download.","commonSituations":"Assuming every country has all portfolio variants (e.g. top/bottom decile files) available; typos in portfolio names; upstream renames of portfolio files after provider release.","solutions":["Check the valid portfolio choices in the query param definition (Literal/choices of FamaFrenchCountryPortfolioReturnsQueryParams) and pick a listed one.","Verify the country+portfolio pair exists in the Fama-French international returns library before querying.","Retry to rule out a transient FTP empty response.","Update the openbb-famafrench provider for current file mappings."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from openbb_famafrench.models.country_portfolio_returns import (\n    FamaFrenchCountryPortfolioReturnsQueryParams,\n)\nimport typing\n\nvalid_portfolios = typing.get_args(\n    FamaFrenchCountryPortfolioReturnsQueryParams.model_fields['portfolio'].annotation\n)","typeGuard":null,"tryCatchPattern":"try:\n    res = await obb.economy.famafrench.country_portfolio_returns(portfolio=p, country=c, provider='famafrench')\nexcept OpenBBError as e:\n    if 'invalid, or incorrectly mapped, portfolio choice' in str(e):\n        logger.warning('Skipping unmapped portfolio %s for %s', p, c)\n        continue\n    raise","preventionTips":["Source portfolio choices from the query model's Literal, not free text","Verify country/portfolio pairs exist in the Fama-French library for batch pipelines"],"tags":["famafrench","portfolio-returns","empty-data","validation"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}