[BUG] structured output validation crashes on None or dict content
Author: MohammadHijjawi97Created Sep 17, 2026Updated Sep 17, 2026
Description
BaseLLM._validate_structured_output calls response.strip() without checking the type. Native structured output can already be a dict, and some providers pass content=None. Both raise AttributeError before schema validation.
Steps to Reproduce
from pydantic import BaseModel
from crewai.llms.base_llm import BaseLLM
class Out(BaseModel):
city: str
BaseLLM._validate_structured_output(None, Out)
BaseLLM._validate_structured_output({"city": "London"}, Out)Expected behavior
None is treated as empty. A dict is validated directly. Strings keep the current JSON parse path.
Screenshots/Code snippets
AttributeError: 'NoneType' object has no attribute 'strip'
Operating System
Windows 11
Python Version
3.12
crewAI Version
main
Source: crewAIInc/crewAI