{"record":{"id":"09d51c3254181f39","repo":"OpenBB-finance/OpenBB","slug":"field-exclude-tag-names-requires-tag-names-to","errorCode":null,"errorMessage":"Field 'exclude_tag_names' requires 'tag_names' to be set.","messagePattern":"Field 'exclude_tag_names' requires 'tag_names' to be set\\.","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/fred/openbb_fred/models/search.py","lineNumber":175,"sourceCode":"            and not transformed_params.get(\"series_id\")\n        ):\n            transformed_params[\"search_type\"] = \"release\"\n        elif (\n            not transformed_params.get(\"query\")\n            and (\n                transformed_params.get(\"search_type\") in [\"full_text\", \"series_id\"]\n                or not transformed_params.get(\"search_type\")\n            )\n            and not transformed_params.get(\"series_id\")\n        ):\n            raise OpenBBError(\n                \"A query is required for search_type 'full_text' or 'series_id'.\"\n            )\n\n        if transformed_params.get(\"exclude_tag_names\") and not transformed_params.get(\n            \"tag_names\"\n        ):\n            raise OpenBBError(\n                \"Field 'exclude_tag_names' requires 'tag_names' to be set.\"\n            )\n\n        return FredSearchQueryParams.model_validate(transformed_params)\n\n    @staticmethod\n    async def aextract_data(\n        query: FredSearchQueryParams,\n        credentials: dict[str, str] | None,\n        **kwargs: Any,\n    ) -> list[dict]:\n        \"\"\"Extract the raw data.\"\"\"\n        # pylint: disable=import-outside-toplevel\n        import asyncio  # noqa\n        from openbb_core.provider.utils.helpers import get_querystring\n        from openbb_fred.utils.rate_limiter import fred_get\n\n        api_key = credentials.get(\"fred_api_key\") if credentials else \"\"","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/fred/openbb_fred/models/search.py#L157-L193","documentation":"Raised in FredSearchFetcher.transform_query (openbb_fred/models/search.py:175) when 'exclude_tag_names' is set but 'tag_names' is empty. FRED's search API only accepts exclusion tags as a modifier of an inclusive tag filter, so the provider rejects the combination up front. Pure client-side validation; nothing is sent to FRED.","triggerScenarios":"fred_search(query='cpi', exclude_tag_names='discontinued') without tag_names; programmatically copying an exclude list into params while the include list is conditionally empty.","commonSituations":"UIs that let users type 'tags to exclude' independently of 'tags to include'; refactors that renamed the inclusive field but left the exclusive one populated.","solutions":["Add the corresponding 'tag_names' value, e.g. tag_names='cpi', exclude_tag_names='discontinued'.","Or remove 'exclude_tag_names' from the request entirely.","Guard at the call site: only set exclude_tag_names when tag_names is truthy."],"exampleFix":"# before\nobb.economy.fred.search(query='prices', exclude_tag_names='discontinued')\n\n# after\nobb.economy.fred.search(query='prices', tag_names='cpi', exclude_tag_names='discontinued')","handlingStrategy":"validation","validationCode":"if params.get('exclude_tag_names') and not params.get('tag_names'):\n    params.pop('exclude_tag_names')  # or raise your own validation error","typeGuard":"def tags_are_consistent(p: dict) -> bool:\n    \"\"\"exclude_tag_names is only legal together with tag_names.\"\"\"\n    return not (bool(p.get('exclude_tag_names')) and not p.get('tag_names'))","tryCatchPattern":null,"preventionTips":["Model tag_names/exclude_tag_names as one optional pair in your config, never independent fields.","Strip exclude_tag_names automatically when the user provides no inclusive tags."],"tags":["fred","search","validation","tags"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}