[BUG] structured output validation crashes on None or dict content
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start at crewai/llms/base_llm.py and inspect BaseLLM._validate_structured_output, then reproduce the None and dict cases from the issue. Done means None is treated as empty, dictionaries are validated directly, and strings retain the current JSON parsing path without AttributeError.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Python
- Stars
- 58.8k
- Forks
- 8.5k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 103
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from crewAIInc/crewAI
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
[BUG] AttributeError: 'int' object has no attribute 'get' in crew_run_tui.py during plan rendering Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
All issues in crewAIInc/crewAI
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100