OpenBB-finance/OpenBB · error · ValueError
Invalid country, {country}, must be one of {list(COUNTRIES_D
Error message
Invalid country, {country}, must be one of {list(COUNTRIES_DICT)} What it means
EconDbYieldCurveQueryParams.validate_country raises ValueError for any comma-separated country token not present in COUNTRIES_DICT (the provider's supported yield-curve countries). Validation runs at query construction, so the error surfaces before any network call; the message lists all accepted values.
Source
Thrown at openbb_platform/providers/econdb/openbb_econdb/models/yield_curve.py:51
)
use_cache: bool = Field(
default=True,
description="If true, cache the request for four hours.",
)
@field_validator("country", mode="before", check_fields=False)
@classmethod
def validate_country(cls, v) -> str:
"""Validate the country."""
if v is None:
return "united_states"
countries = v.split(",")
new_countries: list = []
for country in countries:
if country not in COUNTRIES_DICT:
raise ValueError(
f"Invalid country, {country}, must be one of {list(COUNTRIES_DICT)}"
)
new_countries.append(country)
return ",".join(new_countries)
class EconDbYieldCurveData(YieldCurveData):
"""EconDB Yield Curve Data."""
class EconDbYieldCurveFetcher(
Fetcher[EconDbYieldCurveQueryParams, list[EconDbYieldCurveData]]
):
"""EconDB Yield Curve Fetcher."""
require_credentials = False
View on GitHub (pinned to 3e071fcc2c)
Solutions
- Read the accepted values from the error message and use one exactly (e.g. 'united_states').
- Query only countries you know EconDB publishes yield curves for (a small set — the message enumerates it).
- For multiple countries pass a comma-joined string of valid keys: 'united_states,japan'-style values drawn from the listed set.
Example fix
# before obb.economy.yield_curve(provider='econdb', country='US') # after obb.economy.yield_curve(provider='econdb', country='united_states')
Defensive patterns
Strategy: validation
Validate before calling
from openbb_econdb.models.yield_curve import COUNTRIES_DICT
requested = ['united_states', 'japan']
invalid = [c for c in requested if c not in COUNTRIES_DICT]
if invalid:
raise ValueError(f'econdb yield curve supports only {list(COUNTRIES_DICT)}; got {invalid}') Type guard
def is_supported_yield_country(c: str) -> bool:
from openbb_econdb.models.yield_curve import COUNTRIES_DICT
return c in COUNTRIES_DICT Try / catch
try:
res = obb.economy.yield_curve(provider='econdb', country=country)
except Exception as e:
if 'must be one of' in str(e):
country = 'united_states'
res = obb.economy.yield_curve(provider='econdb', country=country)
else:
raise Prevention
- Use the exact dict keys ('united_states', not 'US'/'USA').
- Validate against COUNTRIES_DICT before calling.
- Note validation is exact-match, case-sensitive.
When it happens
Trigger: economy.yield_curve(provider='econdb', country='usa'/'US'/'japan') — the dict keys are specific identifiers (e.g. 'united_states'); any other spelling is rejected.
Common situations: Using ISO codes or display names from other providers; typo; assuming case-insensitivity (the check is exact).
Related errors
- No valid countries were supplied.
- No valid countries were supplied.
- The 'main' indicator cannot be combined with multiple countr
- Invalid symbol: '{symbol}'. It must have a two-letter countr
- No valid combination of indicator symbols and countries were
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/04fee461e690ca0b.
Report an issue: GitHub.