{"record":{"id":"90e2f3153f434c94","repo":"BerriAI/litellm","slug":"safety-settings-must-be-a-list","errorCode":null,"errorMessage":"safety_settings must be a list","messagePattern":"safety_settings must be a list","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/vertex_ai/vertex_ai_non_gemini.py","lineNumber":165,"sourceCode":"            )\n            vertexai.init(\n                project=vertex_project,\n                location=vertex_location,\n                credentials=cast(Credentials, creds),\n            )\n\n        ## Load Config\n        config: Final = litellm.VertexAIConfig.get_config()\n        for k, v in config.items():\n            if k not in optional_params:\n                optional_params[k] = v\n\n        ## Process safety settings into format expected by vertex AI\n        safety_settings = None\n        if \"safety_settings\" in optional_params:\n            safety_settings = optional_params.pop(\"safety_settings\")\n            if not isinstance(safety_settings, list):\n                raise ValueError(\"safety_settings must be a list\")\n            if len(safety_settings) > 0 and not isinstance(safety_settings[0], dict):\n                raise ValueError(\"safety_settings must be a list of dicts\")\n            safety_settings = [gapic_content_types.SafetySetting(x) for x in safety_settings]\n\n        # vertexai does not use an API key, it looks for credentials.json in the environment\n\n        prompt: Final = \" \".join(\n            [message.get(\"content\") for message in messages if isinstance(message.get(\"content\", None), str)]\n        )\n\n        mode = \"\"\n\n        request_str = \"\"\n        response_obj: Final = None\n        instances = None\n        client_options: Final = {\"api_endpoint\": f\"{vertex_location}-aiplatform.googleapis.com\"}\n        fake_stream = False\n        if model in litellm.vertex_language_models or model in litellm.vertex_vision_models:","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/vertex_ai/vertex_ai_non_gemini.py#L147-L183","documentation":"Type guard while processing safety_settings for a Vertex AI non-Gemini call: the value popped from optional_params is not a list as the Vertex SDK expects, so it is rejected before being passed to the model.","triggerScenarios":"Thrown at litellm/llms/vertex_ai/vertex_ai_non_gemini.py:165 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass safety_settings as a list, e.g. [{'category': 'HARM_CATEGORY_...', 'threshold': 'BLOCK_...'}].","Convert a single dict into a one-element list before passing it."],"exampleFix":null,"handlingStrategy":"type-guard","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"}