{"record":{"id":"660204e2e53143e7","repo":"OpenBB-finance/OpenBB","slug":"no-data-available-for-the-given-parameters-co","errorCode":null,"errorMessage":"No data available for the given parameters. -> {commodity} | {attribute} | {country} | {start_year}-{end_year}","messagePattern":"No data available for the given parameters\\. -> (.+?) \\| (.+?) \\| (.+?) \\| (.+?)-(.+?)","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"warning","filePath":"openbb_platform/providers/government_us/openbb_government_us/utils/psd_data_downloader.py","lineNumber":484,"sourceCode":"        except Exception:\n            return []\n\n    async def fetch_all_batches():\n        \"\"\"Fetch all batches concurrently.\"\"\"\n        async with await get_async_requests_session() as session:\n            tasks = [fetch_batch(session, batch) for batch in attr_batches]\n            results = await asyncio.gather(*tasks)\n            # Flatten results\n            all_results = []\n            for r in results:\n                all_results.extend(r)\n            return all_results\n\n    # Run async fetch\n    result = run_async(fetch_all_batches)\n\n    if not result:\n        raise OpenBBError(\n            \"No data available for the given parameters. -> \"\n            + f\"{commodity} | {attribute} | {country} | {start_year}-{end_year}\"\n        )\n\n    df = DataFrame(result)\n\n    # API only fills commodity/attribute on first row of each group - forward fill\n    df[\"commodity\"] = df[\"commodity\"].ffill()\n    df[\"attribute\"] = df[\"attribute\"].ffill()\n\n    # Find year columns (format: 2024/2025)\n    year_cols = [c for c in df.columns if \"/\" in c and c[0:4].isdigit()]\n    name_to_code = {name.strip(): code for name, code in valid_countries_map.items()}\n    # Also add region display names for lookup\n    for region_code, region_name in REGION_DISPLAY.items():\n        name_to_code[region_name] = region_code\n\n    # Build region name lookup (for detecting when \"country\" is actually a region)","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/government_us/openbb_government_us/utils/psd_data_downloader.py#L466-L502","documentation":"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.","triggerScenarios":"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.","commonSituations":"Backfills requesting start_year far in the past (e.g. 1960) for commodities with data only from 1990; valid-but-empty intersections after filtering.","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."],"exampleFix":"# before\nget_psd_data(commodity, attribute, country, start_year=1960, end_year=1965)\n\n# after\nget_psd_data(commodity, attribute, country, start_year=2000, end_year=None)","handlingStrategy":"fallback","validationCode":"def plausible_year_range(commodity_history_start: int, start_year: int | None, end_year: int | None) -> bool:\n    latest = datetime.now().year\n    start = start_year or commodity_history_start\n    end = end_year or latest\n    return start <= latest and end >= commodity_history_start and start <= end","typeGuard":null,"tryCatchPattern":"try:\n    df = get_psd_data(commodity, attribute, country, start_year, end_year)\nexcept OpenBBError as e:\n    if \"No data available\" in str(e):\n        df = get_psd_data(commodity, attribute, country, None, None)  # retry unfiltered\n        df = df[(df[\"_year\"] >= (start_year or 0)) & (df[\"_year\"] <= (end_year or 9999))] if not df.empty else df\n    else:\n        raise","preventionTips":["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."],"tags":["empty-data","psd","query","year-range"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}