OpenBB-finance/OpenBB · error · ValueError

Please provide either an index or a country, not both at the

Error message

Please provide either an index or a country, not both at the same time.

What it means

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.

Source

Thrown at openbb_platform/providers/famafrench/openbb_famafrench/utils/helpers.py:533

def get_international_portfolio_data(
    index: str | None = None,
    country: str | None = None,
    dividends: bool = True,
) -> str:
    """Download and extract the international index or country portfolio data.

    Note: Not intended for direct use, this function is called by `get_international_portfolio`.
    """
    # pylint: disable=import-outside-toplevel
    import zipfile
    from io import BytesIO

    url: str = ""
    data: str = ""
    if not index and not country:
        raise ValueError("Please provide either an index or a country.")
    if index and country:
        raise ValueError(
            "Please provide either an index or a country, not both at the same time."
        )
    if index:
        index = INTERNATIONAL_INDEX_PORTFOLIO_FILES.get(index)

        if not index:
            raise ValueError(
                f"Index {index} not found in available indexes: "
                + f"{INTERNATIONAL_INDEX_PORTFOLIO_FILES}"
            )
        url = (
            BASE_URL
            + INTERNATIONAL_INDEX_PORTFOLIOS_URLS["dividends" if dividends else "ex"]
        )
    if country:
        country = country.title().replace("_", " ")
        if country not in list(COUNTRY_PORTFOLIO_FILES):
            raise ValueError(

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Remove one of the two parameters so exactly one remains.
  2. If you need both, issue two separate calls, one per index/country.
  3. Add a pre-call assertion in your code: (bool(index)) != (bool(country)).

Example fix

// before
obb.economy.famafrench.international_index_returns(index='Developed', country='Japan')

// after
obb.economy.famafrench.international_index_returns(index='Developed')
Defensive patterns

Strategy: validation

Validate before calling

assert bool(index) != bool(country), 'Pass exactly one of index or country'

Prevention

When it happens

Trigger: Calling international portfolio returns with non-empty values for both index and country in one request.

Common situations: Copy-pasting a params dict that includes both fields; UI form that pre-fills defaults for both selectors.

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/8a440edd1b06a079. Report an issue: GitHub.