{"record":{"id":"c4c8ef057c57965e","repo":"OpenBB-finance/OpenBB","slug":"invalid-chokepoint-value-v-expected-a-string","errorCode":null,"errorMessage":"Invalid chokepoint value: {v} -> Expected a string or a list of strings from {list(CHOKEPOINTS_NAME_TO_ID)}. - or chokepointN, where N is a number between 1 and 24","messagePattern":"Invalid chokepoint value: (.+?) -> Expected a string or a list of strings from (.+?)\\. - 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":100,"sourceCode":"\n            return (\n                v\n                if v in CHOKEPOINTS_NAME_TO_ID\n                or v in list(CHOKEPOINTS_NAME_TO_ID.values())\n                else None\n            )\n\n        if isinstance(v, list):\n            chokepoints = []\n            for d in v:\n                if d in CHOKEPOINTS_NAME_TO_ID:\n                    chokepoints.append(CHOKEPOINTS_NAME_TO_ID[d])\n                elif d in list(CHOKEPOINTS_NAME_TO_ID.values()):\n                    chokepoints.append(d)\n\n            return \",\".join(chokepoints) if chokepoints else None\n\n        raise OpenBBError(\n            ValueError(\n                f\"Invalid chokepoint value: {v} -> \"\n                f\"Expected a string or a list of strings from {list(CHOKEPOINTS_NAME_TO_ID)}.\"\n                \" - or chokepointN, where N is a number between 1 and 24\"\n            )\n        )\n\n\nclass ImfMaritimeChokePointVolumeData(MaritimeChokePointVolumeData):\n    \"\"\"IMF Maritime Chokepoint Volume Data.\n\n    Source: https://portwatch.imf.org/datasets/42132aa4e2fc4d41bdaf9a445f688931/about\n    \"\"\"\n\n    model_config = ConfigDict(\n        extra=\"ignore\",\n        validate_by_alias=True,\n        validate_by_name=True,","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/imf/openbb_imf/models/maritime_chokepoint_volume.py#L82-L118","documentation":"Terminal branch of the `chokepoint` field validator reached when the value is neither a string, a list, nor falsy — i.e. an int, dict, or other type. Note that a list of unknown strings does NOT raise here: it is silently filtered to known names, so this error is purely about the Python type of the input.","triggerScenarios":"Passing `chokepoint=7` (bare int id), `chokepoint={'id': 7}`, or another non-string/list type. Strings and lists fall into earlier branches; anything else reaches this raise.","commonSituations":"Assuming the numeric chokepoint id can be passed as an integer (it must be the string 'chokepoint7'); passing a dict from an upstream config; pandas/numpy scalar types leaking in.","solutions":["Pass a string name, a 'chokepointN' string id, a comma-separated string, or a list of strings.","Convert numeric ids to 'chokepoint{N}' strings before calling.","Coerce untrusted input with str() and validate against the known names first."],"exampleFix":"# before\nmaritime_chokepoint_volume(chokepoint=7)\n\n# after\nmaritime_chokepoint_volume(chokepoint='chokepoint7')","handlingStrategy":"type-guard","validationCode":"if not isinstance(chokepoint, (str, list)) or not all(isinstance(x, str) for x in ([chokepoint] if isinstance(chokepoint, str) else chokepoint)):\n    chokepoint = str(chokepoint)  # or reject","typeGuard":"def is_chokepoint_input(v) -> bool:\n    if isinstance(v, str):\n        return True\n    return isinstance(v, list) and all(isinstance(x, str) for x in v)","tryCatchPattern":null,"preventionTips":["Convert numeric ids to 'chokepoint{N}' strings at your boundary","Reject dicts/ints early with a clear message"],"tags":["imf","portwatch","validation","type-error","chokepoint"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}