OpenBB-finance/OpenBB · warning · OpenBBError
No data available for the given parameters. -> {commodity} |
Error message
No data available for the given parameters. -> {commodity} | {attribute} | {country} | {start_year}-{end_year} What it means
OpenBBError raised after run_async completes the batched PSD API queries and the flattened result list is empty. All HTTP calls succeeded but the RunQuery endpoint returned no rows for the requested commodity/attribute/country/year combination. The message echoes the exact parameters to identify the empty combination.
Source
Thrown at openbb_platform/providers/government_us/openbb_government_us/utils/psd_data_downloader.py:484
except Exception:
return []
async def fetch_all_batches():
"""Fetch all batches concurrently."""
async with await get_async_requests_session() as session:
tasks = [fetch_batch(session, batch) for batch in attr_batches]
results = await asyncio.gather(*tasks)
# Flatten results
all_results = []
for r in results:
all_results.extend(r)
return all_results
# Run async fetch
result = run_async(fetch_all_batches)
if not result:
raise OpenBBError(
"No data available for the given parameters. -> "
+ f"{commodity} | {attribute} | {country} | {start_year}-{end_year}"
)
df = DataFrame(result)
# API only fills commodity/attribute on first row of each group - forward fill
df["commodity"] = df["commodity"].ffill()
df["attribute"] = df["attribute"].ffill()
# Find year columns (format: 2024/2025)
year_cols = [c for c in df.columns if "/" in c and c[0:4].isdigit()]
name_to_code = {name.strip(): code for name, code in valid_countries_map.items()}
# Also add region display names for lookup
for region_code, region_name in REGION_DISPLAY.items():
name_to_code[region_name] = region_code
# Build region name lookup (for detecting when "country" is actually a region)View on GitHub (pinned to 3e071fcc2c)
Solutions
- Widen the year range or use start_year/end_year=None.
- Verify the combination yields data on the USDA PSD Online site for those years.
- Loop over attributes individually to isolate which combination is empty.
Example fix
# before get_psd_data(commodity, attribute, country, start_year=1960, end_year=1965) # after get_psd_data(commodity, attribute, country, start_year=2000, end_year=None)
Defensive patterns
Strategy: fallback
Validate before calling
def plausible_year_range(commodity_history_start: int, start_year: int | None, end_year: int | None) -> bool:
latest = datetime.now().year
start = start_year or commodity_history_start
end = end_year or latest
return start <= latest and end >= commodity_history_start and start <= end Try / catch
try:
df = get_psd_data(commodity, attribute, country, start_year, end_year)
except OpenBBError as e:
if "No data available" in str(e):
df = get_psd_data(commodity, attribute, country, None, None) # retry unfiltered
df = df[(df["_year"] >= (start_year or 0)) & (df["_year"] <= (end_year or 9999))] if not df.empty else df
else:
raise Prevention
- Query without year filters first, then slice locally, when coverage is uncertain.
- Learn each commodity's earliest marketing year before backfilling.
- Treat this as an empty-result condition, not a crash; log and continue in pipelines.
When it happens
Trigger: A year range wholly outside the commodity's reporting history; a country/attribute combination that exists in metadata but has no rows; marketing-year data starting later than start_year for that commodity.
Common situations: Backfills requesting start_year far in the past (e.g. 1960) for commodities with data only from 1990; valid-but-empty intersections after filtering.
Related errors
- OBBject Extension Error -> An OBBject extension that acts
- [Empty] -> {e}
- Error: No validated data was found.
- Error: No data to plot.
- No data to process!
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/660204e2e53143e7.
Report an issue: GitHub.