{"record":{"id":"6e723a25103117a2","repo":"OpenBB-finance/OpenBB","slug":"industry-must-be-one-of-join-industries","errorCode":null,"errorMessage":"Industry must be one of {', '.join(industries)}","messagePattern":"Industry must be one of (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/fmp/openbb_fmp/models/equity_screener.py","lineNumber":162,"sourceCode":"    is_fund: bool | None = Field(\n        default=None,\n        description=\"If true, includes funds.\",\n    )\n    all_share_classes: bool | None = Field(\n        default=None,\n        description=\"If true, includes all share classes of a equity.\",\n    )\n    limit: int | None = Field(\n        default=50000, description=\"Limit the number of results to return.\"\n    )\n\n    @field_validator(\"industry\")\n    @classmethod\n    def _validate_industry(cls, v):\n        \"\"\"Validate industry.\"\"\"\n        industries = [v[\"value\"] for v in IndustryChoices]\n        if v and v not in industries + [\"all\"]:\n            raise ValueError(f\"Industry must be one of {', '.join(industries)}\")\n        return v\n\n    @field_validator(\"country\", mode=\"after\")\n    @classmethod\n    def _validate_country(cls, v):\n        \"\"\"Validate country is supported by FMP.\"\"\"\n        if v is None:\n            return v\n        # Country stores alpha_2 in uppercase, FMP expects lowercase\n        country_code = v.alpha_2.lower()\n        valid_countries = list(Countries.__args__)\n        if country_code not in valid_countries:\n            raise ValueError(\n                f\"Country '{v.name}' ({v.alpha_2}) is not supported by FMP. \"\n                f\"Valid options: {', '.join(sorted(valid_countries)[:20])}...\"\n            )\n        return v\n","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/fmp/openbb_fmp/models/equity_screener.py#L144-L180","documentation":"A Pydantic field_validator ValueError on FMPEquityScreenerQueryParams.industry: the industry string must either be 'all' or one of the literal values defined in the IndustryChoices enum. Any other free-text value is rejected client-side before the request.","triggerScenarios":"Calling obb.equity.screener(provider='fmp', industry='...') with a value not in IndustryChoices - e.g. 'Software Engineering' instead of 'Software', or a sector name like 'Technology' in the industry field.","commonSituations":"Passing human-readable or sector-level names where a specific industry literal is required, hardcoded industry lists drifting out of sync with the enum after package updates, casing/spacing mismatches ('real estate' vs 'Real Estate').","solutions":["Use exactly the enum values from openbb_fmp - inspect IndustryChoices (e.g. [v.value for v in IndustryChoices]) and pick the matching literal","Use 'all' to skip industry filtering and post-filter client-side if your label has no equivalent","Catch the pydantic ValidationError and re-present the allowed list to the user/UI"],"exampleFix":"# before\nres = obb.screener.equity(provider='fmp', industry='Tech Software')  # ValueError\n\n# after\nfrom openbb_fmp.models.equity_screener import IndustryChoices\nvalid = [v.value for v in IndustryChoices]\nindustry = next((v for v in valid if 'software' in v.lower()), 'all')\nres = obb.screener.equity(provider='fmp', industry=industry)","handlingStrategy":"validation","validationCode":"from openbb_fmp.models.equity_screener import IndustryChoices\nVALID_INDUSTRIES = {v.value for v in IndustryChoices} | {'all'}\nindustry = industry if industry in VALID_INDUSTRIES else 'all'","typeGuard":"def is_valid_fmp_industry(v: str) -> bool:\n    from openbb_fmp.models.equity_screener import IndustryChoices\n    return v == 'all' or v in {i.value for i in IndustryChoices}","tryCatchPattern":"from pydantic import ValidationError\ntry:\n    res = obb.screener.equity(provider='fmp', industry=industry)\nexcept ValidationError:\n    res = obb.screener.equity(provider='fmp', industry='all')  # then filter client-side","preventionTips":["Derive dropdown options for industry from IndustryChoices instead of hardcoding","After upgrading openbb-fmp, refresh any cached industry lists","Prefer 'all' + client-side filtering for fuzzy labels"],"tags":["fmp","validation","screener","industry","pydantic"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}