OpenBB-finance/OpenBB · error · OpenBBError

Invalid report ID -> {report_id} was not found.

Error message

Invalid report ID -> {report_id} was not found.

What it means

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.

Source

Thrown at openbb_platform/providers/government_us/openbb_government_us/utils/psd_data_downloader.py:121

    >>> df = DataFrame(result['data'])
    >>> # All numeric columns are float64, ready for analysis
    >>> print(df.dtypes)
    """
    # pylint: disable=import-outside-toplevel
    from aiohttp import ClientError  # noqa
    from openbb_core.app.model.abstract.error import OpenBBError
    from openbb_core.provider.utils.helpers import get_async_requests_session
    from openbb_government_us.utils.psd_template_parser import parse_report

    # Get template ID for this report
    template_id = None
    for group_data in PSD_REPORTS_METADATA.values():
        if report_id in group_data["reports"]:
            template_id = group_data["reports"][report_id]["templateId"]
            break

    if template_id is None:
        raise OpenBBError(f"Invalid report ID -> {report_id} was not found.")

    # Build URLs for both formats
    html_url = get_report_url(report_id, "html")
    csv_url = get_report_url(report_id, "csv")
    session = await get_async_requests_session()

    try:
        # Fetch both HTML (for units) and CSV (for data)
        html_resp = await session.get(html_url)
        html = await html_resp.text()
        csv_resp = await session.get(csv_url)
        csv_text = await csv_resp.text()
    except ClientError as e:
        raise OpenBBError(f"Error fetching report {report_id} -> {e}") from e
    finally:
        await session.close()

    # Check for server error

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Use list_reports() to enumerate valid ids and their metadata.
  2. Upgrade openbb-platform / the government_us provider to refresh the report mapping.
  3. Verify the id against the USDA PSD Online 'reports' page.

Example fix

# before
data = await get_psd_report_data(1234)  # not in metadata

# after
from openbb_government_us.utils.psd_data_downloader import list_reports
valid = next(r for r in list_reports() if ...)  # choose real id
data = await get_psd_report_data(valid_id)
Defensive patterns

Strategy: validation

Validate before calling

from openbb_government_us.utils.psd_data_downloader import PSD_REPORTS_METADATA

def resolve_template_id(report_id: int) -> int | None:
    for g in PSD_REPORTS_METADATA.values():
        if report_id in g["reports"]:
            return g["reports"][report_id]["templateId"]
    return None

Try / catch

try:
    data = await get_psd_report_data(report_id)
except OpenBBError as e:
    if "was not found" in str(e):
        # refresh the id from list_reports() and retry once
        raise
    raise

Prevention

When it happens

Trigger: Calling the PSD report fetcher (psd_data_downloader.get_psd_report_data) with an id absent from PSD_REPORTS_METADATA.

Common situations: Same as the metadata-miss case: stale library metadata vs. the live USDA catalog, or a mistyped id.

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/73e8d8eee4465ee7. Report an issue: GitHub.