OpenBB-finance/OpenBB · error · OpenBBError

Invalid chokepoint name: {v} -> Expected one of {list(CHOKEP

Error message

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

What it means

The single-value branch of the same `chokepoint` field validator: the string contains no comma but is neither a CHOKEPOINTS_NAME_TO_ID key nor one of its values, so it is rejected before any network call. Message mirrors the comma variant — valid names list plus the chokepointN id escape hatch.

Source

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

                    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)}"
                        " - or chokepointN, where N is a number between 1 and 24"
                    )
                )

            return (
                v
                if v in CHOKEPOINTS_NAME_TO_ID
                or v in list(CHOKEPOINTS_NAME_TO_ID.values())
                else None
            )

        if isinstance(v, list):
            chokepoints = []
            for d in v:
                if d in CHOKEPOINTS_NAME_TO_ID:

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Copy the exact chokepoint name from the validator's listed options, or pass its chokepointN id.
  2. Match casing and punctuation exactly (the comparison is case-sensitive).
  3. If unsure of the id, call maritime_chokepoint_info once to see canonical names.

Example fix

# before
maritime_chokepoint_volume(chokepoint='panama')

# after
maritime_chokepoint_volume(chokepoint='Panama Canal')
Defensive patterns

Strategy: validation

Validate before calling

from openbb_imf.models.maritime_chokepoint_volume import CHOKEPOINTS_NAME_TO_ID
if chokepoint not in CHOKEPOINTS_NAME_TO_ID and chokepoint not in CHOKEPOINTS_NAME_TO_ID.values():
    raise ValueError(f'unknown chokepoint: {chokepoint}')

Type guard

def is_valid_chokepoint(s: str) -> bool:
    return s in CHOKEPOINTS_NAME_TO_ID or s in CHOKEPOINTS_NAME_TO_ID.values()

Prevention

When it happens

Trigger: Passing one misspelled or aliased chokepoint name, e.g. `chokepoint='panama'` (lowercase) or `'Malacca strait'`, where exact key 'Malacca Strait' is required; ids are matched case-sensitively too.

Common situations: Quick single-chokepoint lookups typed from memory; casing/punctuation drift from the official names; passing a port name instead of a chokepoint name.

Related errors


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