{"record":{"id":"1d2cbee75f025b70","repo":"BerriAI/litellm","slug":"invalid-template-message-type-type-template-mess","errorCode":null,"errorMessage":"Invalid template message type: {type(template_message)}","messagePattern":"Invalid template message type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/humanloop.py","lineNumber":88,"sourceCode":"            headers={\n                \"X-Api-Key\": humanloop_api_key,\n                \"Content-Type\": \"application/json\",\n            },\n        )\n\n        try:\n            response.raise_for_status()\n        except httpx.HTTPStatusError as e:\n            raise Exception(f\"Error getting prompt from Humanloop: {e.response.text}\")\n\n        json_response: Final = response.json()\n        template_message: Final = json_response[\"template\"]\n        if isinstance(template_message, dict):\n            template_messages = [template_message]\n        elif isinstance(template_message, list):\n            template_messages = template_message\n        else:\n            raise ValueError(f\"Invalid template message type: {type(template_message)}\")\n        template_model: Final = json_response[\"model\"]\n        optional_params: Final = {}\n        for k, v in json_response.items():\n            if k in litellm.OPENAI_CHAT_COMPLETION_PARAMS:\n                optional_params[k] = v\n        return PromptManagementClient(\n            prompt_id=humanloop_prompt_id,\n            prompt_template=cast(list[AllMessageValues], template_messages),\n            model=template_model,\n            optional_params=optional_params,\n        )\n\n    def _get_prompt_from_id(self, humanloop_prompt_id: str, humanloop_api_key: str) -> PromptManagementClient:\n        prompt = self._get_prompt_from_id_cache(humanloop_prompt_id)\n        if prompt is None:\n            prompt = self._get_prompt_from_id_api(humanloop_prompt_id, humanloop_api_key)\n            self.set_cache(\n                key=humanloop_prompt_id,","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/humanloop.py#L70-L106","documentation":"Humanloop integration guard: the 'template' field fetched from the Humanloop API response is neither a dict nor a list, i.e. an unexpected payload shape the template-message handler cannot process.","triggerScenarios":"A Humanloop prompt template contains a message entry of an unexpected type.","commonSituations":"Template fetched in an unexpected format or hand-built template with malformed entries.","solutions":["Ensure each template message is a dict or a supported message type, not a raw string or other object."],"exampleFix":"template = [{'role': 'user', 'content': 'Hello {{name}}'}]","handlingStrategy":"validation","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-23T08:17:48.524Z"}