{"record":{"id":"41990112f1b16dd1","repo":"OpenBB-finance/OpenBB","slug":"no-ratings-data-returned-419901","errorCode":null,"errorMessage":"No ratings data returned.","messagePattern":"No ratings data returned\\.","errorType":"exception","errorClass":"EmptyDataError","httpStatus":null,"severity":"warning","filePath":"openbb_platform/providers/benzinga/openbb_benzinga/models/price_target.py","lineNumber":305,"sourceCode":"\n        token = credentials.get(\"benzinga_api_key\") if credentials else \"\"\n        base_url = \"https://api.benzinga.com/api/v2.1/calendar/ratings\"\n        query.limit = query.limit or 200\n        querystring = get_querystring(query.model_dump(by_alias=True), [])\n\n        url = f\"{base_url}?{querystring}&token={token}\"\n        data = await amake_request(url, response_callback=response_callback, **kwargs)\n\n        if isinstance(data, dict) and \"ratings\" not in data:\n            raise OpenBBError(\n                f\"Unexpected data format. Expected 'ratings' key, got: {list(data.keys())}\"\n            )\n        if not isinstance(data, dict):\n            raise OpenBBError(\n                f\"Unexpected data format. Expected dict, got: {type(data)}\"\n            )\n        if isinstance(data, dict) and not data.get(\"ratings\"):\n            raise EmptyDataError(\"No ratings data returned.\")\n\n        return data[\"ratings\"]\n\n    @staticmethod\n    def transform_data(\n        query: BenzingaPriceTargetQueryParams,\n        data: list[dict],\n        **kwargs: Any,\n    ) -> list[BenzingaPriceTargetData]:\n        \"\"\"Return the transformed data.\"\"\"\n        results: list[BenzingaPriceTargetData] = []\n        # Remove duplicated field with a URL\n        for item in data:\n            item.pop(\"url_calendar\", None)\n            results.append(BenzingaPriceTargetData.model_validate(item))\n        return results\n","sourceCodeStart":287,"sourceCodeEnd":322,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/benzinga/openbb_benzinga/models/price_target.py#L287-L322","documentation":"Raised by the Benzinga price_target fetcher when the API call succeeds but the response dict contains a 'ratings' key that is empty, null, or a falsy value. It signals that Benzinga acknowledged the request but has no analyst ratings records for the queried parameters. This is an EmptyDataError, meaning it maps to a 'no data' condition rather than a transport or auth failure.","triggerScenarios":"Calling openbb.stocks.dd.price_target() with a symbol that has no Benzinga analyst coverage (small caps, recent IPOs, delisted tickers), a date_range outside available coverage, or a valid response like {\"ratings\": []} / {\"ratings\": null}. Any falsy value for data.get(\"ratings\") triggers it.","commonSituations":"Developers batch-fetching price targets for a universe of tickers where some have no analyst coverage; using an expired or wrong token may also cause Benzinga to return an empty ratings array instead of an error.","solutions":["Verify the symbol actually has analyst coverage on Benzinga's website","Check that the benzinga_api_key credential is valid and not exhausted (a bad token can yield empty ratings instead of an auth error)","Wrap the call and treat EmptyDataError as 'no coverage', continuing with the next symbol","Relax query parameters (e.g. wider date range, with_rating only when data exists)"],"exampleFix":"// before\nfrom openbb import obb\ndata = obb.stocks.dd.price_target(symbol='OBSCURE_TICKER')  # raises EmptyDataError\n\n// after\nfrom openbb_core.provider.utils.errors import EmptyDataError\ntry:\n    data = obb.stocks.dd.price_target(symbol='OBSCURE_TICKER')\nexcept EmptyDataError:\n    data = None  # no analyst coverage for this symbol","handlingStrategy":"try-catch","validationCode":"from openbb_core.provider.utils.errors import EmptyDataError\n\ndef has_ratings(func, *args, **kwargs):\n    try:\n        return func(*args, **kwargs).results\n    except EmptyDataError:\n        return []","typeGuard":null,"tryCatchPattern":"try:\n    data = obb.stocks.dd.price_target(symbol=symbol)\nexcept EmptyDataError:\n    data = None  # symbol has no analyst coverage; skip or record","preventionTips":["Pre-screen ticker universes for analyst coverage before batch price-target pulls","Treat EmptyDataError as a normal outcome for coverage-based endpoints","Monitor API key health separately - a bad token can masquerade as empty ratings"],"tags":["benzinga","empty-data","analyst-ratings","provider"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}