{"record":{"id":"73e8d8eee4465ee7","repo":"OpenBB-finance/OpenBB","slug":"invalid-report-id-report-id-was-not-found","errorCode":null,"errorMessage":"Invalid report ID -> {report_id} was not found.","messagePattern":"Invalid report ID -> (.+?) was not found\\.","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/government_us/openbb_government_us/utils/psd_data_downloader.py","lineNumber":121,"sourceCode":"    >>> df = DataFrame(result['data'])\n    >>> # All numeric columns are float64, ready for analysis\n    >>> print(df.dtypes)\n    \"\"\"\n    # pylint: disable=import-outside-toplevel\n    from aiohttp import ClientError  # noqa\n    from openbb_core.app.model.abstract.error import OpenBBError\n    from openbb_core.provider.utils.helpers import get_async_requests_session\n    from openbb_government_us.utils.psd_template_parser import parse_report\n\n    # Get template ID for this report\n    template_id = None\n    for group_data in PSD_REPORTS_METADATA.values():\n        if report_id in group_data[\"reports\"]:\n            template_id = group_data[\"reports\"][report_id][\"templateId\"]\n            break\n\n    if template_id is None:\n        raise OpenBBError(f\"Invalid report ID -> {report_id} was not found.\")\n\n    # Build URLs for both formats\n    html_url = get_report_url(report_id, \"html\")\n    csv_url = get_report_url(report_id, \"csv\")\n    session = await get_async_requests_session()\n\n    try:\n        # Fetch both HTML (for units) and CSV (for data)\n        html_resp = await session.get(html_url)\n        html = await html_resp.text()\n        csv_resp = await session.get(csv_url)\n        csv_text = await csv_resp.text()\n    except ClientError as e:\n        raise OpenBBError(f\"Error fetching report {report_id} -> {e}\") from e\n    finally:\n        await session.close()\n\n    # Check for server error","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/government_us/openbb_government_us/utils/psd_data_downloader.py#L103-L139","documentation":"OpenBBError raised in get_psd_report_data when no template_id can be resolved for the report_id by scanning PSD_REPORTS_METADATA. It is the async-path duplicate of the metadata miss: every report in the mapping carries a templateId used to parse output, so an id without an entry cannot proceed.","triggerScenarios":"Calling the PSD report fetcher (psd_data_downloader.get_psd_report_data) with an id absent from PSD_REPORTS_METADATA.","commonSituations":"Same as the metadata-miss case: stale library metadata vs. the live USDA catalog, or a mistyped id.","solutions":["Use list_reports() to enumerate valid ids and their metadata.","Upgrade openbb-platform / the government_us provider to refresh the report mapping.","Verify the id against the USDA PSD Online 'reports' page."],"exampleFix":"# before\ndata = await get_psd_report_data(1234)  # not in metadata\n\n# after\nfrom openbb_government_us.utils.psd_data_downloader import list_reports\nvalid = next(r for r in list_reports() if ...)  # choose real id\ndata = await get_psd_report_data(valid_id)","handlingStrategy":"validation","validationCode":"from openbb_government_us.utils.psd_data_downloader import PSD_REPORTS_METADATA\n\ndef resolve_template_id(report_id: int) -> int | None:\n    for g in PSD_REPORTS_METADATA.values():\n        if report_id in g[\"reports\"]:\n            return g[\"reports\"][report_id][\"templateId\"]\n    return None","typeGuard":null,"tryCatchPattern":"try:\n    data = await get_psd_report_data(report_id)\nexcept OpenBBError as e:\n    if \"was not found\" in str(e):\n        # refresh the id from list_reports() and retry once\n        raise\n    raise","preventionTips":["Treat list_reports() output as the single source of truth for ids.","Keep the provider updated so PSD_REPORTS_METADATA tracks the USDA catalog."],"tags":["validation","psd","metadata"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}