{"record":{"id":"8a440edd1b06a079","repo":"OpenBB-finance/OpenBB","slug":"please-provide-either-an-index-or-a-country-not-b","errorCode":null,"errorMessage":"Please provide either an index or a country, not both at the same time.","messagePattern":"Please provide either an index or a country, not both at the same time\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/famafrench/openbb_famafrench/utils/helpers.py","lineNumber":533,"sourceCode":"def get_international_portfolio_data(\n    index: str | None = None,\n    country: str | None = None,\n    dividends: bool = True,\n) -> str:\n    \"\"\"Download and extract the international index or country portfolio data.\n\n    Note: Not intended for direct use, this function is called by `get_international_portfolio`.\n    \"\"\"\n    # pylint: disable=import-outside-toplevel\n    import zipfile\n    from io import BytesIO\n\n    url: str = \"\"\n    data: str = \"\"\n    if not index and not country:\n        raise ValueError(\"Please provide either an index or a country.\")\n    if index and country:\n        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(","sourceCodeStart":515,"sourceCodeEnd":551,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/famafrench/openbb_famafrench/utils/helpers.py#L515-L551","documentation":"Raised by get_international_portfolio_data when both `index` and `country` are supplied at the same time. The two map to different files in the Fama/French international library, so the helper explicitly rejects the ambiguous request instead of picking one.","triggerScenarios":"Calling international portfolio returns with non-empty values for both index and country in one request.","commonSituations":"Copy-pasting a params dict that includes both fields; UI form that pre-fills defaults for both selectors.","solutions":["Remove one of the two parameters so exactly one remains.","If you need both, issue two separate calls, one per index/country.","Add a pre-call assertion in your code: (bool(index)) != (bool(country))."],"exampleFix":"// before\nobb.economy.famafrench.international_index_returns(index='Developed', country='Japan')\n\n// after\nobb.economy.famafrench.international_index_returns(index='Developed')","handlingStrategy":"validation","validationCode":"assert bool(index) != bool(country), 'Pass exactly one of index or country'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enforce mutual exclusivity in form validation before submission.","Issue separate calls per index/country rather than combining parameters."],"tags":["famafrench","validation","mutually-exclusive"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}