{"record":{"id":"a112865a1b583912","repo":"OpenBB-finance/OpenBB","slug":"country-must-be-a-string-or-list-of-strings-got","errorCode":null,"errorMessage":"Country must be a string or list of strings. Got {type(v)}","messagePattern":"Country must be a string or list of strings\\. Got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/government_us/openbb_government_us/models/commodity_psd_data.py","lineNumber":276,"sourceCode":"        return attributes\n\n    @field_validator(\"country\", mode=\"before\", check_fields=False)\n    @classmethod\n    def _validate_country(cls, v):\n        \"\"\"Validate country.\"\"\"\n        if not v:\n            return None\n\n        if v and isinstance(v, list) and not v[0]:\n            return None\n\n        countries = v\n\n        if isinstance(countries, str):\n            countries = [countries] if \",\" not in countries else countries.split(\",\")\n\n        if not isinstance(countries, list):\n            raise ValueError(\n                f\"Country must be a string or list of strings. Got {type(v)}\"\n            )\n\n        if isinstance(countries, list) and len(countries) == 1 and \",\" in countries[0]:\n            countries = countries[0].split(\",\")\n\n        invalid_countries = [\n            country\n            for country in countries\n            if country\n            and country not in COUNTRY_CHOICES.values()\n            and country not in COUNTRY_CHOICES\n        ]\n\n        if invalid_countries:\n            raise ValueError(\n                f\"Invalid country code(s) '{', '.join(invalid_countries)}'. Valid country codes are: \"\n                + \", \".join(","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/government_us/openbb_government_us/models/commodity_psd_data.py#L258-L294","documentation":"Error \"Country must be a string or list of strings. Got {type(v)}\" thrown in OpenBB-finance/OpenBB.","triggerScenarios":"Thrown at openbb_platform/providers/government_us/openbb_government_us/models/commodity_psd_data.py:276 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the country as a string or a list of strings.","Remove any non-string items from the country list."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}