OpenBB-finance/OpenBB · error · OpenBBError

Error downloading the file from the EIA site -> {e}

Error message

Error downloading the file from the EIA site -> {e}

What it means

Broad wrapper in the EIA helpers around amake_request for the Excel workbook download (used by the Petroleum Status Report and similar file-based endpoints). Any failure downloading the .xlsx — including the 403 key callback above, timeouts, or a response body that pandas cannot open as Excel — becomes this OpenBBError with the cause appended.

Source

Thrown at openbb_platform/providers/eia/openbb_us_eia/utils/helpers.py:43

    # pylint: disable=import-outside-toplevel
    from io import BytesIO  # noqa
    from openbb_core.provider.utils.helpers import amake_request
    from pandas import ExcelFile

    async def callback(response, _):
        """Read the response and return the ExcelFile object."""
        res = await response.read()
        file = ExcelFile(BytesIO(res))
        return file

    # Clear the cache to download the file again.
    if use_cache is False:
        download_excel_file.cache_invalidate(url)

    try:
        return await amake_request(url, response_callback=callback)
    except Exception as e:  # pylint: disable=broad-except
        raise OpenBBError(f"Error downloading the file from the EIA site -> {e}") from e

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Read the appended cause: an api_key message means fix credentials (see error 331); a parse/InvalidFile message means the URL returned non-Excel content.
  2. Retry with use_cache=False to bypass a poisoned cache entry.
  3. Update the openbb-us-eia provider — WpsrFileMap URLs are corrected there when EIA moves files.
  4. Check network/proxy access to eia.gov.
Defensive patterns

Strategy: retry

Try / catch

try:
    res = await obb.energy.petroleum_status_report(category=cat, provider='eia')
except OpenBBError as e:
    msg = str(e)
    if 'api_key' in msg:
        raise RuntimeError('EIA credentials problem') from e
    if 'downloading' in msg:  # transient or poisoned cache
        res = await obb.energy.petroleum_status_report(category=cat, provider='eia', use_cache=False)
    else:
        raise

Prevention

When it happens

Trigger: HTTP 403 with an API-key error (wrapped from response_callback); HTML error page instead of xlsx (stale WpsrFileMap URL); pandas raising on a non-Excel payload in the inner callback; DNS/proxy failures reaching eia.gov.

Common situations: Missing EIA API key (the file endpoints also require it); EIA site restructures moving file paths; proxies returning error pages; cached broken downloads being replayed until the alru_cache expires.

Related errors


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