OpenBB-finance/OpenBB · error · OpenBBError
not a valid source. Valid sources
Error message
{query.source} not a valid source. Valid sources: {sources} What it means
Raised by the Biztoc world_news fetcher when query.source is provided but its lowercase form is not in the list of source IDs fetched live from the Biztoc /sources endpoint. The valid set is discovered at runtime, so the error message itself contains the authoritative list. This is an OpenBBError caused purely by invalid user input.
Solutions
- Read the valid ids from the error message itself - it prints the current list
- Query https://biztoc.p.rapidapi.com/sources once to cache the source catalog before batch jobs
- Use the exact lowercase id (e.g. 'blm', 'bbc', 'nbc') rather than display names
- Leave source unset to get latest news across all sources
Example fix
// before obb.news(provider='biztoc', source='BBC News') # OpenBBError: not a valid source // after obb.news(provider='biztoc', source='bbc') # use the source id from /sources
Defensive patterns
Strategy: validation
Validate before calling
import requests
def valid_biztoc_sources(key: str) -> set[str]:
r = requests.get('https://biztoc.p.rapidapi.com/sources',
headers={'X-RapidAPI-Key': key,
'X-RapidAPI-Host': 'biztoc.p.rapidapi.com'})
return {s['id'] for s in r.json()}
# assert my_source.lower() in valid_biztoc_sources(key) before calling Try / catch
try:
news = obb.news(provider='biztoc', source=src)
except OpenBBError as e:
if 'not a valid source' in str(e):
print('invalid source; valid list in message:', e) Prevention
- Fetch and cache the /sources catalog once per session
- Use source ids, never display names
- Parse the valid list straight out of the error message when it fires
When it happens
Trigger: Calling obb.news(provider='biztoc', source='Bloomberg') when Biztoc's source id is e.g. 'blm' - full display names, wrong casing with no match, or sources that Biztoc dropped since the last check.
Common situations: Developers guessing source names instead of ids; source catalogs changing over time; passing a source valid in another provider (e.g. FMP's source values) to Biztoc.
Related errors
- Required field missing -> symbol
- Required field missing -> symbol
- Unauthorized Biztoc request ->
- A query is required for search_type 'full_text' or…
- A query must be provided when no dataflows and keywords are…
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/5bfe5ca7815f0d6e.
Report an issue: GitHub.
Appendix: source
Thrown at openbb_platform/providers/biztoc/openbb_biztoc/models/world_news.py:127
"Accept-Encoding": "gzip",
}
base_url = "https://biztoc.p.rapidapi.com/"
url = ""
response: list | dict = []
if query.term:
query.term = query.term.replace(" ", "%20")
url = base_url + f"search?q={query.term}"
response = await amake_request(
url, headers=headers, response_callback=response_callback
)
elif query.source is not None:
sources_response = make_request(
"https://biztoc.p.rapidapi.com/sources",
headers=headers,
).json()
sources = [source["id"] for source in sources_response]
if query.source.lower() not in sources:
raise OpenBBError(
f"{query.source} not a valid source. Valid sources: {sources}"
)
url = base_url + f"news/source/{query.source.lower()}"
response = await amake_request(
url, headers=headers, response_callback=response_callback
)
else:
url1 = base_url + "news/latest"
response = await amake_request(
url1, headers=headers, response_callback=response_callback
)
return response # type: ignore
@staticmethod
def transform_data(
query: BiztocWorldNewsQueryParams, data: list[dict], **kwargs: Any
) -> list[BiztocWorldNewsData]:View on GitHub (pinned to 3e071fcc2c)