{"record":{"id":"6ba66c7010172c0e","repo":"OpenBB-finance/OpenBB","slug":"invalid-filters-dict-format-must-be-a-dictionar","errorCode":null,"errorMessage":"Invalid 'filters_dict' format. Must be a dictionary or serialized JSON string.","messagePattern":"Invalid 'filters_dict' format\\. Must be a dictionary or serialized JSON string\\.","errorType":"validation","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/finviz/openbb_finviz/models/equity_screener.py","lineNumber":168,"sourceCode":"            raise OpenBBError(\n                f\"Invalid preset '{v}'. Please rename the file to use as a preset.\"\n            )\n        return v if v else None\n\n    @field_validator(\"filters_dict\", mode=\"before\", check_fields=False)\n    @classmethod\n    def validate_filters_dict(cls, v):\n        \"\"\"Validate the filters_dict.\"\"\"\n        if isinstance(v, str):\n            # pylint: disable=import-outside-toplevel\n            import json\n\n            try:\n                v = json.loads(v)\n            except json.JSONDecodeError as e:\n                raise OpenBBError(f\"Invalid JSON format for 'filters_dict': {e}\") from e\n        if v is not None and not isinstance(v, dict):\n            raise OpenBBError(\n                \"Invalid 'filters_dict' format. Must be a dictionary or serialized JSON string.\"\n            )\n\n        return v\n\n\nclass FinvizEquityScreenerData(EquityScreenerData):\n    \"\"\"Finviz Equity Screener Data. Actual returned data varies by the 'metric' parameter.\"\"\"\n\n    __alias_dict__ = {\n        \"symbol\": \"Ticker\",\n        \"name\": \"Company\",\n        \"earnings_date\": \"Earnings\",\n        \"sector\": \"Sector\",\n        \"industry\": \"Industry\",\n        \"country\": \"Country\",\n        \"shares_outstanding\": \"Outstanding\",\n        \"shares_float\": \"Float\",","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/finviz/openbb_finviz/models/equity_screener.py#L150-L186","documentation":"Raised when filters_dict is neither None, a dict, nor a JSON string that decodes to a dict (e.g. the string parsed fine but produced a list or scalar). The provider requires a mapping of screener filter keys to allowed values.","triggerScenarios":"Passing filters_dict as a list of tuples; passing '[1,2,3]' (valid JSON but not an object); passing a set or a pandas Series.","commonSituations":"Programmatically deriving filters from tabular data (rows/Series) instead of a mapping; over-general serialization code that emits arrays.","solutions":["Supply a plain dict mapping Finviz filter names to values","If converting from another structure, build the dict explicitly before passing","Add an isinstance(x, dict) assert in calling code during development"],"exampleFix":"# before\nq = FinvizEquityScreenerQueryParams(filters_dict=[(\"Debt/Equity\", \"Over 0.5\")])\n\n# after\nq = FinvizEquityScreenerQueryParams(filters_dict={\"Debt/Equity\": \"Over 0.5\"})","handlingStrategy":"type-guard","validationCode":"assert filters_dict is None or isinstance(filters_dict, dict), (\n    \"filters_dict must be a dict (or JSON string decoding to a dict)\"\n)","typeGuard":"def is_filters_dict(v) -> bool:\n    if v is None:\n        return True\n    if isinstance(v, dict):\n        return True\n    if isinstance(v, str):\n        try:\n            return isinstance(json.loads(v), dict)\n        except json.JSONDecodeError:\n            return False\n    return False","tryCatchPattern":null,"preventionTips":["Convert tabular/paired data to a dict explicitly before passing","Assert the type at the call site during development"],"tags":["openbb","finviz","validation","filters","type-error"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}