OpenBB-finance/OpenBB · error · ValueError

Please provide either an index or a country.

Error message

Please provide either an index or a country.

What it means

Raised inside get_international_portfolio_data when both `index` and `country` are falsy. The international portfolios dataset is keyed by either a market index or a single country, and the helper refuses to guess which file to download.

Source

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


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("_", " ")

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Pass exactly one of index or country, e.g. index='Developed' or country='Japan'.
  2. Check the endpoint's parameter choices (INTERNATIONAL_INDEX_PORTFOLIO_FILES / COUNTRY_PORTFOLIO_FILES) for valid values.
  3. Guard upstream code so at least one parameter is always provided.

Example fix

// before
obb.economy.famafrench.international_index_returns(country=None, index=None)

// after
obb.economy.famafrench.international_index_returns(country='Japan')
Defensive patterns

Strategy: validation

Validate before calling

if not index and not country:
    raise ValueError('Provide index or country before calling famafrench international returns')

Prevention

When it happens

Trigger: Calling international index/country returns with neither index nor country set (both None or empty strings).

Common situations: Building query params dynamically and both fields end up empty; passing an empty string instead of None; assuming the model has a default portfolio.

Related errors


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