OpenBB-finance/OpenBB · error · ValueError

Attribute must be a string or list of strings. Got {type(v)}

Error message

Attribute must be a string or list of strings. Got {type(v)}

What it means

Error "Attribute must be a string or list of strings. Got {type(v)}" thrown in OpenBB-finance/OpenBB.

Source

Thrown at openbb_platform/providers/government_us/openbb_government_us/models/commodity_psd_data.py:246

        if v and isinstance(v, list) and not v[0]:
            return None

        attributes = v

        if isinstance(attributes, str):
            attributes = (
                [attributes] if "," not in attributes else attributes.split(",")
            )

        if (
            isinstance(attributes, list)
            and len(attributes) == 1
            and "," in attributes[0]
        ):
            attributes = attributes[0].split(",")

        if not isinstance(attributes, list):
            raise ValueError(
                f"Attribute must be a string or list of strings. Got {type(v)}"
            )

        invalid_attrs = [attr for attr in attributes if attr not in ATTRIBUTES]

        if invalid_attrs:
            raise ValueError(
                f"Invalid attribute(s) '{', '.join(invalid_attrs)}'. Valid attributes are: "
                + ", ".join(sorted(list(ATTRIBUTES)))
            )

        return attributes

    @field_validator("country", mode="before", check_fields=False)
    @classmethod
    def _validate_country(cls, v):
        """Validate country."""
        if not v:

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Pass the attribute as a string or a list of strings.
  2. Remove any non-string items from the attribute list.

When it happens

Trigger: Thrown at openbb_platform/providers/government_us/openbb_government_us/models/commodity_psd_data.py:246 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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