{"record":{"id":"3f0cf8a208ada846","repo":"OpenBB-finance/OpenBB","slug":"invalid-chokepoint-name-chokepoint-expected","errorCode":null,"errorMessage":"Invalid chokepoint name: {chokepoint} -> Expected one of {list(CHOKEPOINTS_NAME_TO_ID)} - or chokepointN, where N is a number between 1 and 24","messagePattern":"Invalid chokepoint name: (.+?) -> Expected one of (.+?) - or chokepointN, where N is a number between 1 and 24","errorType":"validation","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/imf/openbb_imf/models/maritime_chokepoint_volume.py","lineNumber":60,"sourceCode":"        description=\"Name of the chokepoint. Use `None` for all chokepoints.\"\n        + f\" Choices are: {CHOKEPOINT_DOCSTRING}\",\n    )\n\n    @field_validator(\"chokepoint\", mode=\"before\")\n    @classmethod\n    def validate_chokepoint(cls, v):\n        \"\"\"Validate the chokepoint parameter.\"\"\"\n        if not v:\n            return None\n\n        if isinstance(v, str):\n            if \",\" in v:\n                chokepoints = v.split(\",\")\n                for chokepoint in chokepoints:\n                    if chokepoint not in list(\n                        CHOKEPOINTS_NAME_TO_ID\n                    ) and chokepoint not in list(CHOKEPOINTS_NAME_TO_ID.values()):\n                        raise OpenBBError(\n                            ValueError(\n                                f\"Invalid chokepoint name: {chokepoint} -> \"\n                                f\"Expected one of {list(CHOKEPOINTS_NAME_TO_ID)}\"\n                                \" - or chokepointN, where N is a number between 1 and 24\"\n                            )\n                        )\n\n                return \",\".join(chokepoints) if chokepoints else None\n\n            if (\n                v\n                and v not in CHOKEPOINTS_NAME_TO_ID\n                and v not in list(CHOKEPOINTS_NAME_TO_ID.values())\n            ):\n                raise OpenBBError(\n                    ValueError(\n                        f\"Invalid chokepoint name: {v} -> \"\n                        f\"Expected one of {list(CHOKEPOINTS_NAME_TO_ID)}\"","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/imf/openbb_imf/models/maritime_chokepoint_volume.py#L42-L78","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use an exact key from CHOKEPOINTS_NAME_TO_ID or a chokepointN id (e.g. 'chokepoint7').","Strip whitespace around each comma-separated token before passing.","Print/inspect the map keys (or the parameter description) to copy the exact spelling."],"exampleFix":"# before\nobb.economy.imf.maritime_chokepoint_volume(chokepoint='Hormuz, Suez Canal')\n\n# after\nobb.economy.imf.maritime_chokepoint_volume(chokepoint='Strait of Hormuz,Suez Canal')","handlingStrategy":"validation","validationCode":"from openbb_imf.models.maritime_chokepoint_volume import CHOKEPOINTS_NAME_TO_ID\nVALID = set(CHOKEPOINTS_NAME_TO_ID) | set(CHOKEPOINTS_NAME_TO_ID.values())\ntokens = [t.strip() for t in chokepoint_str.split(',')]\nbad = [t for t in tokens if t not in VALID]\nassert not bad, f'unknown chokepoints: {bad}'","typeGuard":"def is_valid_chokepoint_csv(s: str) -> bool:\n    toks = [t.strip() for t in s.split(',')]\n    return all(t in CHOKEPOINTS_NAME_TO_ID or t in CHOKEPOINTS_NAME_TO_ID.values() for t in toks)","tryCatchPattern":null,"preventionTips":["Normalize whitespace after commas before passing","Source names from CHOKEPOINTS_NAME_TO_ID keys, never free text"],"tags":["imf","portwatch","validation","chokepoint","query-params"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}