OpenBB-finance/OpenBB · error · OpenBBError

Asset '{asset}' not supported. Expected .json or .xz file.

Error message

Asset '{asset}' not supported. Expected .json or .xz file.

What it means

Raised by the BLS asset loader when the requested asset name contains neither '.json' nor '.xz' and does not match the 'series'/'codes' auto-suffix rules. The loader only supports the packaged JSON code maps and xz-compressed series CSVs, so any other filename is rejected before hitting the filesystem. It is an input-validation OpenBBError.

Source

Thrown at openbb_platform/providers/bls/openbb_bls/utils/helpers.py:380

def open_asset(asset: str) -> Union["DataFrame", dict]:
    """Open a static file asset for series IDs or code maps."""
    # pylint: disable=import-outside-toplevel
    import os  # noqa
    import json
    from importlib.resources import files
    from pathlib import Path
    from numpy import nan
    from openbb_core.app.model.abstract.error import OpenBBError
    from pandas import read_csv

    if ".xz" not in asset and "series" in asset:
        asset = asset + ".xz"
    elif ".json" not in asset and "codes" in asset:
        asset = asset + ".json"
    elif ".json" in asset or ".xz" in asset:
        pass
    else:
        raise OpenBBError(f"Asset '{asset}' not supported. Expected .json or .xz file.")

    assets_path = Path(str(files("openbb_bls").joinpath("assets")))

    if not os.path.exists(assets_path.joinpath(asset)):
        raise OpenBBError(f"Asset '{asset}' not found.")

    if asset.endswith(".json"):
        with open(assets_path.joinpath(asset)) as f:
            return json.load(f)
    else:
        with open(assets_path.joinpath(asset), "rb") as f:
            df = read_csv(f, compression="xz", low_memory=False, dtype="str")
        return df.replace({nan: None, "nan": None, "''": None}).dropna(
            how="all", axis=1
        )


async def update_static_asset(category: str) -> None:

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Pass a bare filename ending in .json or .xz, or containing 'series'/'codes' so the extension is auto-appended
  2. Verify the file exists under openbb_bls/assets/
  3. If a new asset type is genuinely needed, extend the loader's branch chain rather than bypassing it

Example fix

# before
df = get_survey_asset('cu_series')  # no auto-match -> OpenBBError

# after
df = get_survey_asset('cu_series.xz')  # explicit supported extension
Defensive patterns

Strategy: validation

Validate before calling

def is_supported_asset(name: str) -> bool:
    return name.endswith(('.json', '.xz')) or 'series' in name or 'codes' in name

Type guard

def is_supported_asset(name: str) -> bool:
    return name.endswith(('.json', '.xz')) or 'series' in name or 'codes' in name

Prevention

When it happens

Trigger: Calling get_survey_asset('foo') or get_survey_asset('series.txt') - a name with no recognized extension and no 'series'/'codes' substring to auto-append one; also names like 'metadata.csv'.

Common situations: Contributors adding new asset types (e.g. parquet) without updating the loader; typos in asset names inside helpers; passing a full path instead of a bare filename.

Related errors


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