{"record":{"id":"a4b6387d469e72b6","repo":"BerriAI/litellm","slug":"data-json-get-error","errorCode":null,"errorMessage":"data_json.get(\"error\")","messagePattern":"data_json\\.get\\(\"error\"\\)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/litellm_core_utils/streaming_handler.py","lineNumber":484,"sourceCode":"                chunk = chunk.decode(\"utf-8\")  # DO NOT REMOVE this: This is required for HF inference API + Streaming\n            text = \"\"\n            is_finished = False\n            finish_reason = \"\"\n            print_verbose(f\"chunk: {chunk}\")\n            if chunk.startswith(\"data:\"):\n                data_json: Final[_PredibaseStreamData] = json.loads(chunk[5:])\n                print_verbose(f\"data json: {data_json}\")\n                if \"token\" in data_json and \"text\" in data_json[\"token\"]:\n                    text = data_json[\"token\"][\"text\"]\n                if data_json.get(\"details\", False) and data_json[\"details\"].get(\"finish_reason\", False):\n                    is_finished = True\n                    finish_reason = data_json[\"details\"][\"finish_reason\"]\n                elif data_json.get(\"generated_text\", False):  # if full generated text exists, then stream is complete\n                    text = \"\"  # don't return the final bos token\n                    is_finished = True\n                    finish_reason = \"stop\"\n                elif data_json.get(\"error\", False):\n                    raise Exception(data_json.get(\"error\"))\n                return {\n                    \"text\": text,\n                    \"is_finished\": is_finished,\n                    \"finish_reason\": finish_reason,\n                }\n            elif \"error\" in chunk:\n                raise ValueError(chunk)\n            return {\n                \"text\": text,\n                \"is_finished\": is_finished,\n                \"finish_reason\": finish_reason,\n            }\n        except Exception as e:\n            raise e\n\n    def handle_ai21_chunk(self, chunk):  # fake streaming\n        chunk = chunk.decode(\"utf-8\")\n        data_json: Final[_Ai21StreamData] = json.loads(chunk)","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/litellm_core_utils/streaming_handler.py#L466-L502","documentation":"In the Predibase stream chunk handler, when a parsed SSE payload contains a top-level 'error' key the handler raises Exception with that value, surfacing the upstream error from the Predibase inference server.","triggerScenarios":"Streaming a completion with custom_llm_provider='predibase' where the server emits {\"error\": ...} frames — invalid model/adapter id, expired Predibase token, or a request the deployed LLM rejects mid-stream.","commonSituations":"Wrong adapter_id or model name for a Predibase deployment; revoked API key; Predibase deployment restarting/terminated; payload exceeds server limits.","solutions":["Read the exception message — it echoes Predibase's own error text (auth vs model vs capacity).","Verify the Predibase API token and the adapter/deployment id in your call.","Confirm the deployment is running and the model string matches Predibase's docs for litellm.","Retry after the deployment is healthy; this is a server-side error frame, not a parsing bug."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    for part in litellm.completion(model=\"predibase/...\", stream=True, ...):\n        process(part)\nexcept Exception as e:\n    log.error(\"Predibase stream error frame: %s\", e)\n    raise UpstreamProviderError(\"predibase\") from e","preventionTips":["Smoke-test the Predibase deployment with a 1-token non-streaming call before streaming.","Keep adapter ids and tokens in config and validate them at startup."],"tags":["predibase","streaming","upstream-error","provider"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}