{"record":{"id":"dce2876a2e93c13e","repo":"BerriAI/litellm","slug":"the-response-was-blocked-by-vertexai-vertex-chun","errorCode":null,"errorMessage":"The response was blocked by VertexAI. {vertex_chunk}","messagePattern":"The response was blocked by VertexAI\\. (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/litellm_core_utils/streaming_handler.py","lineNumber":1347,"sourceCode":"                                        },\n                                        \"type\": \"function\",\n                                    }\n                                ],\n                            )\n                            _streaming_response: Final = StreamingChoices(delta=_delta_obj)\n                            _model_response: Final = ModelResponseStream()\n                            _model_response.choices = [_streaming_response]\n                            response_obj = {\"original_chunk\": _model_response}\n                        else:\n                            raise original_exception\n                    if (\n                        hasattr(vertex_chunk.candidates[0], \"finish_reason\")\n                        and vertex_chunk.candidates[0].finish_reason.name != \"FINISH_REASON_UNSPECIFIED\"\n                    ):  # every non-final chunk in vertex ai has this\n                        self.received_finish_reason = map_finish_reason(vertex_chunk.candidates[0].finish_reason.name)\n                except Exception:\n                    if vertex_chunk.candidates[0].finish_reason.name == \"SAFETY\":\n                        raise Exception(f\"The response was blocked by VertexAI. {vertex_chunk}\")\n            else:\n                completion_obj[\"content\"] = str(vertex_chunk)\n        elif self.custom_llm_provider == \"petals\":\n            if self.completion_stream is None or len(self.completion_stream) == 0:\n                if self.received_finish_reason is not None:\n                    raise StopIteration\n                else:\n                    self.received_finish_reason = \"stop\"\n            chunk_size = 30\n            stream = cast(Any, self.completion_stream)\n            new_chunk = stream[:chunk_size]\n            completion_obj[\"content\"] = new_chunk\n            self.completion_stream = stream[chunk_size:]\n        elif self.custom_llm_provider == \"palm\":\n            # fake streaming\n            response_obj = {}\n            if self.completion_stream is None or len(self.completion_stream) == 0:\n                if self.received_finish_reason is not None:","sourceCodeStart":1329,"sourceCodeEnd":1365,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/streaming_handler.py#L1329-L1365","documentation":"Vertex AI streaming guard: the stream contains a block signaling Vertex blocked the response (safety/policy filtering); instead of returning empty content, the chunk is surfaced as an exception with the raw payload so callers know generation was suppressed.","triggerScenarios":"Thrown at litellm/litellm_core_utils/streaming_handler.py:1347 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["VertexAI safety filters blocked the response; revise the prompt or adjust safety settings.","Inspect vertex_chunk for the block reason."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}