OpenBB-finance/OpenBB · error · OpenBBError

Invalid chokepoint name: {chokepoint} -> Expected one of {li

Error message

Invalid chokepoint name: {chokepoint} -> Expected one of {list(CHOKEPOINTS_NAME_TO_ID)} - or chokepointN, where N is a number between 1 and 24

What it means

Pydantic field validator on the `chokepoint` parameter (comma-separated string branch) rejecting a token that is neither a key (display name) nor a value (chokepointN id) in CHOKEPOINTS_NAME_TO_ID. The error names the offending token and enumerates all valid names, and reminds that chokepointN ids (N = 1..24) are accepted.

Source

Thrown at openbb_platform/providers/imf/openbb_imf/models/maritime_chokepoint_volume.py:60

        description="Name of the chokepoint. Use `None` for all chokepoints."
        + f" Choices are: {CHOKEPOINT_DOCSTRING}",
    )

    @field_validator("chokepoint", mode="before")
    @classmethod
    def validate_chokepoint(cls, v):
        """Validate the chokepoint parameter."""
        if not v:
            return None

        if isinstance(v, str):
            if "," in v:
                chokepoints = v.split(",")
                for chokepoint in chokepoints:
                    if chokepoint not in list(
                        CHOKEPOINTS_NAME_TO_ID
                    ) and chokepoint not in list(CHOKEPOINTS_NAME_TO_ID.values()):
                        raise OpenBBError(
                            ValueError(
                                f"Invalid chokepoint name: {chokepoint} -> "
                                f"Expected one of {list(CHOKEPOINTS_NAME_TO_ID)}"
                                " - or chokepointN, where N is a number between 1 and 24"
                            )
                        )

                return ",".join(chokepoints) if chokepoints else None

            if (
                v
                and v not in CHOKEPOINTS_NAME_TO_ID
                and v not in list(CHOKEPOINTS_NAME_TO_ID.values())
            ):
                raise OpenBBError(
                    ValueError(
                        f"Invalid chokepoint name: {v} -> "
                        f"Expected one of {list(CHOKEPOINTS_NAME_TO_ID)}"

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Use an exact key from CHOKEPOINTS_NAME_TO_ID or a chokepointN id (e.g. 'chokepoint7').
  2. Strip whitespace around each comma-separated token before passing.
  3. Print/inspect the map keys (or the parameter description) to copy the exact spelling.

Example fix

# before
obb.economy.imf.maritime_chokepoint_volume(chokepoint='Hormuz, Suez Canal')

# after
obb.economy.imf.maritime_chokepoint_volume(chokepoint='Strait of Hormuz,Suez Canal')
Defensive patterns

Strategy: validation

Validate before calling

from openbb_imf.models.maritime_chokepoint_volume import CHOKEPOINTS_NAME_TO_ID
VALID = set(CHOKEPOINTS_NAME_TO_ID) | set(CHOKEPOINTS_NAME_TO_ID.values())
tokens = [t.strip() for t in chokepoint_str.split(',')]
bad = [t for t in tokens if t not in VALID]
assert not bad, f'unknown chokepoints: {bad}'

Type guard

def is_valid_chokepoint_csv(s: str) -> bool:
    toks = [t.strip() for t in s.split(',')]
    return all(t in CHOKEPOINTS_NAME_TO_ID or t in CHOKEPOINTS_NAME_TO_ID.values() for t in toks)

Prevention

When it happens

Trigger: Passing `chokepoint='Bab el-Mandeb,Suez'` where one token is misspelled or not exactly a map key; wrong casing, extra whitespace after commas, or a name not in the 24-chokepoint catalog.

Common situations: Free-typing chokepoint names instead of copying from the documented list; using a common alias (e.g. 'Hormuz' instead of 'Strait of Hormuz') that is not the map key; trailing spaces from CSV construction.

Related errors


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