{"record":{"id":"b1a710168b3df034","repo":"OpenBB-finance/OpenBB","slug":"invalid-name-s-join-invalid","errorCode":null,"errorMessage":"Invalid {name}(s): {', '.join(invalid)}","messagePattern":"Invalid (.+?)\\(s\\): (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/imf/openbb_imf/utils/dot_helpers.py","lineNumber":207,"sourceCode":"\n        # Parse the selection into a list\n        if isinstance(selection, str):\n            # Check if it contains commas (comma-separated list)\n            selection_list = (\n                [item.strip() for item in selection.split(\",\")]\n                if \",\" in selection\n                else [selection]\n            )\n        else:\n            selection_list = selection\n\n        # Check if any item is a wildcard\n        if \"*\" in selection_list:\n            return \"*\"\n\n        invalid = [item for item in selection_list if item not in valid_values]\n        if invalid:\n            raise ValueError(f\"Invalid {name}(s): {', '.join(invalid)}\")\n        return selection_list if len(selection_list) > 1 else selection_list[0]\n\n    validated_country = _validate_selection(country, country_values, \"country\")\n    validated_counterpart = _validate_selection(\n        counterpart, counterpart_values, \"counterpart\"\n    )\n\n    # For indicator, handle wildcards and comma-separated values the same way\n    if isinstance(indicator, str) and \",\" in indicator:\n        validated_indicator = [item.strip() for item in indicator.split(\",\")]\n    else:\n        validated_indicator = indicator if indicator != \"*\" else \"*\"  # type: ignore\n\n    return query_builder.fetch_data(\n        dataflow=dataflow_id,\n        start_date=start_date,\n        end_date=end_date,\n        FREQUENCY=freq,","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/imf/openbb_imf/utils/dot_helpers.py#L189-L225","documentation":"Raised by the inner _validate_selection in imts_query after checking every country/counterpart entry against the IMTS dataflow's allowed SDMX dimension values (fetched from provider metadata). Unlike the friendlier dot_helpers resolver, this layer expects actual dimension codes, and anything not in the dataflow's COUNTRY/COUNTERPART_COUNTRY value set is rejected with the offending items listed. Wildcards ('*') short-circuit and pass.","triggerScenarios":"Passing snake_case names here when the dimension only contains ISO-style codes (e.g. 'united_states' not in the set but 'USA' is); a valid country that the specific IMTS dataflow does not cover; comma-separated strings where one entry is a typo; deprecated country codes after IMF revisions.","commonSituations":"Mixing the two country vocabularies (resolver-friendly names vs strict dimension codes) in one code path; dataflows whose coverage differs (small economies missing from IMTS); scripts written against older code lists.","solutions":["Pass ISO3-style codes ('USA', 'DEU') that exist in the IMTS dimension — check the invalid list in the message for exactly which entries failed.","Pre-resolve friendly names with the dot_helpers country resolver before calling imts_query.","If you meant 'all', pass '*' rather than enumerating names."],"exampleFix":"# before\nres = imts_query(country='united_states', counterpart='germany', indicator='TXG_FOB_USD')\n\n# after\nfrom openbb_imf.utils.dot_helpers import transform_country\ncountry = transform_country('united_states')   # 'USA'\ncounterpart = transform_country('germany')     # 'DEU'\nres = imts_query(country=country, counterpart=counterpart, indicator='TXG_FOB_USD')","handlingStrategy":"validation","validationCode":"from openbb_imf.utils.query_builder import ImfQueryBuilder\nqb = ImfQueryBuilder()\nparams = qb.metadata.get_dataflow_parameters('IMTS')\nvalid = {i['value'] for i in params.get('COUNTRY', [])}\nselected = [c for c in country_list if c in valid or c == '*']\nif not selected:\n    raise ValueError(f'No valid IMTS countries; valid set sample: {sorted(valid)[:5]}')","typeGuard":"def are_valid_imts_selections(values: list[str], valid: set[str]) -> bool:\n    return '*' in values or all(v in valid for v in values)","tryCatchPattern":"try:\n    res = imts_query(country=c, counterpart=cp, indicator=ind)\nexcept ValueError as e:\n    if e.args and e.args[0].startswith('Invalid '):\n        # re-resolve names via transform_country, then retry\n        c = [transform_country(x) for x in c]\n        res = imts_query(country=c, counterpart=cp, indicator=ind)\n    else:\n        raise","preventionTips":["Pre-resolve friendly names with the dot_helpers country resolver before imts_query.","Use '*' instead of enumerating when you mean all.","Parse the invalid list from the message to give users the exact bad entries."],"tags":["validation","imf","country-codes","dot","sdmx","metadata"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}