{"record":{"id":"91a49819b0f34bad","repo":"OpenBB-finance/OpenBB","slug":"country-country-not-found-in-available-countries","errorCode":null,"errorMessage":"Country {country} not found in available countries: {COUNTRY_PORTFOLIO_FILES}","messagePattern":"Country (.+?) not found in available countries: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/famafrench/openbb_famafrench/utils/helpers.py","lineNumber":551,"sourceCode":"        raise ValueError(\n            \"Please provide either an index or a country, not both at the same time.\"\n        )\n    if index:\n        index = INTERNATIONAL_INDEX_PORTFOLIO_FILES.get(index)\n\n        if not index:\n            raise ValueError(\n                f\"Index {index} not found in available indexes: \"\n                + f\"{INTERNATIONAL_INDEX_PORTFOLIO_FILES}\"\n            )\n        url = (\n            BASE_URL\n            + INTERNATIONAL_INDEX_PORTFOLIOS_URLS[\"dividends\" if dividends else \"ex\"]\n        )\n    if country:\n        country = country.title().replace(\"_\", \" \")\n        if country not in list(COUNTRY_PORTFOLIO_FILES):\n            raise ValueError(\n                f\"Country {country} not found in available countries: \"\n                + f\"{COUNTRY_PORTFOLIO_FILES}\"\n            )\n        url = BASE_URL + COUNTRY_PORTFOLIOS_URLS[\"dividends\" if dividends else \"ex\"]\n        index = COUNTRY_PORTFOLIO_FILES[country]\n\n    response = download_international_portfolios(url)\n\n    with zipfile.ZipFile(BytesIO(response.content)) as f:\n        filenames = f.namelist()\n\n        if index in filenames:\n            try:\n                with f.open(index) as file:\n                    data = file.read().decode(\"utf-8\")\n            except UnicodeDecodeError:\n                # Fallback to latin-1 encoding if utf-8 fails\n                with f.open(index) as file:","sourceCodeStart":533,"sourceCodeEnd":569,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/famafrench/openbb_famafrench/utils/helpers.py#L533-L569","documentation":"Raised by get_international_portfolio_data when the normalized country name is not a key in COUNTRY_PORTFOLIO_FILES. Country is title-cased and underscores replaced with spaces before the check, so 'japan' or 'united_kingdom' are valid forms; anything else fails.","triggerScenarios":"Calling international portfolio returns with country='JP', 'U.K.', or any name not in COUNTRY_PORTFOLIO_FILES after title-casing and underscore-to-space normalization.","commonSituations":"Passing country codes ('JP', 'GB') instead of names; non-English country names; countries not covered by the Fama/French country portfolios dataset.","solutions":["Use a full country name that title-cases to a COUNTRY_PORTFOLIO_FILES key, e.g. 'japan', 'united_kingdom', 'United States'.","Check the keys of COUNTRY_PORTFOLIO_FILES in openbb_famafrench/utils/helpers.py for coverage.","Note the normalization: lowercase or underscore forms are fine, but codes and abbreviations are not."],"exampleFix":"// before\nobb.economy.famafrench.international_index_returns(country='JP')\n\n// after\nobb.economy.famafrench.international_index_returns(country='japan')","handlingStrategy":"validation","validationCode":"from openbb_famafrench.utils.helpers import COUNTRY_PORTFOLIO_FILES\nname = country.title().replace('_', ' ')\nif name not in COUNTRY_PORTFOLIO_FILES:\n    raise ValueError(f'{country!r} not covered; choose from {list(COUNTRY_PORTFOLIO_FILES)}')","typeGuard":"def is_valid_ff_country(country: str) -> bool:\n    from openbb_famafrench.utils.helpers import COUNTRY_PORTFOLIO_FILES\n    return country.title().replace('_', ' ') in COUNTRY_PORTFOLIO_FILES","tryCatchPattern":null,"preventionTips":["Use full country names, not ISO codes; underscores and lowercase are normalized.","Load the covered country list once and drive UI choices from it."],"tags":["famafrench","validation","country-choice"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}