{"record":{"id":"538e07624ae6101f","repo":"OpenBB-finance/OpenBB","slug":"k-is-not-a-valid-indicator","errorCode":null,"errorMessage":"{k} is not a valid indicator.","messagePattern":"(.+?) is not a valid indicator\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/obbject_extensions/charting/openbb_charting/query_params.py","lineNumber":851,"sourceCode":"    def __repr__(self):\n        \"\"\"Return the string representation of the model.\"\"\"\n        fields = self.__class__.model_fields\n        repr_str = \"\\n\" + \"\\n\".join(\n            [\n                f\"{str(v.description).replace('IndicatorsQueryParams', ':').replace('ADOs', 'AD Os')}\"\n                for k, v in fields.items()\n            ]\n        )\n        return repr_str\n\n    @model_validator(mode=\"before\")\n    @classmethod\n    def validate_model(cls, values):\n        \"\"\"Validate the model.\"\"\"\n        indicators = list(ChartIndicators.get_available_indicators())\n        for k, v in values.items():\n            if k not in indicators:\n                raise ValueError(f\"{k} is not a valid indicator.\")\n        return values\n","sourceCodeStart":833,"sourceCodeEnd":853,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/obbject_extensions/charting/openbb_charting/query_params.py#L833-L853","documentation":"ChartIndicators (obbject_extensions/charting/query_params.py:851) is a Pydantic model whose keys are TA indicator names; its mode=\"before\" validator rejects any key not present in ChartIndicators.get_available_indicators(), raising ValueError(f\"{k} is not a valid indicator.\"). This is the input gate for the `indicators` dict passed to charting endpoints.","triggerScenarios":"Passing indicators={\"macd\": True, \"vwap\": True, \"supertrend\": {}} where one key (e.g. \"supertrend\") is not in the available set; or a typo like \"rsi \" with trailing whitespace.","commonSituations":"Copy-pasting pandas_ta indicator names that OpenBB hasn't mapped; dicts built from user input or config files without validation; version drift after upgrading openbb-charting changes the supported list.","solutions":["Validate keys against the source of truth before building the model: set(indicators) <= set(ChartIndicators.get_available_indicators()).","Remove or correct the offending key named in the message.","Print ChartIndicators.get_available_indicators() to see the exact accepted spellings for your installed version.","Upgrade/align the openbb-charting package if the indicator you need exists in a newer release."],"exampleFix":"# before\nindicators = {\"sma\": {\"length\": 20}, \"supertrend\": {}}\ncharting.to_chart(data=df, indicators=indicators)  # ValueError: supertrend is not a valid indicator.\n\n# after\nvalid = set(ChartIndicators.get_available_indicators())\nindicators = {k: v for k, v in {\"sma\": {\"length\": 20}, \"supertrend\": {}}.items() if k in valid}\ncharting.to_chart(data=df, indicators=indicators)","handlingStrategy":"validation","validationCode":"from openbb_charting.query_params import ChartIndicators\nallowed = set(ChartIndicators.get_available_indicators())\nbad = set(indicators) - allowed\nif bad:\n    raise ValueError(f\"unsupported indicators: {sorted(bad)}; allowed: {sorted(allowed)}\")\nmodel = ChartIndicators.model_validate(indicators)","typeGuard":"def valid_indicator_keys(payload: dict) -> bool:\n    from openbb_charting.query_params import ChartIndicators\n    return set(payload) <= set(ChartIndicators.get_available_indicators())","tryCatchPattern":"from pydantic import ValidationError\ntry:\n    model = ChartIndicators.model_validate(indicators)\nexcept ValidationError as e:\n    bad = [err[\"loc\"][0] for err in e.errors()]\n    indicators = {k: v for k, v in indicators.items() if k not in bad}\n    model = ChartIndicators.model_validate(indicators)","preventionTips":["Source indicator keys from ChartIndicators.get_available_indicators() for the installed version.","Validate user/config-supplied dicts before passing them to charting endpoints.","Re-check the allowed list after upgrading openbb-charting."],"tags":["python","openbb","charting","pydantic","validation"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}