Skip to content

fix(tasks): rename json property to json_output to avoid BaseModel method conflict#6553

Open
bunnysayzz wants to merge 1 commit into
crewAIInc:mainfrom
bunnysayzz:main
Open

fix(tasks): rename json property to json_output to avoid BaseModel method conflict#6553
bunnysayzz wants to merge 1 commit into
crewAIInc:mainfrom
bunnysayzz:main

Conversation

@bunnysayzz

Copy link
Copy Markdown

Description

Both TaskOutput and CrewOutput inherit from Pydantic's BaseModel, which provides a built-in .json() method. Both classes defined a @property named json which shadowed BaseModel.json(), causing serialization conflicts.

This was acknowledged by a TODO comment in task_output.py.

Changes

  • task_output.py: Renamed @property def json to @property def json_output, removed the TODO comment and # type: ignore[override]
  • crew_output.py: Renamed @property def json to @property def json_output, removed the # type: ignore[override], added a docstring
  • test_task.py: Updated 4 references from result.json to result.json_output, renamed test for consistency

Testing

  • All existing tests pass with the updated property name
  • The renamed property still returns the same JSON string as before
  • Pydantic's native BaseModel.json() method is now accessible again

…thod conflict

The TaskOutput and CrewOutput classes inherit from Pydantic's BaseModel,
which provides a built-in .json() method. Both classes defined a @Property
named 'json' which shadowed BaseModel.json(), causing serialization
conflicts. This renames the property to 'json_output' and updates all
references.

Closes the TODO comment in task_output.py that acknowledged this issue.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bf4da082-51e0-4972-bae8-5aa350895a48

📥 Commits

Reviewing files that changed from the base of the PR and between 0e5d0ec and 13b243d.

📒 Files selected for processing (3)
  • lib/crewai/src/crewai/crews/crew_output.py
  • lib/crewai/src/crewai/tasks/task_output.py
  • lib/crewai/tests/test_task.py

📝 Walkthrough

Walkthrough

Renames CrewOutput.json() to json_output(), changes TaskOutput.json() to a json_output property, and updates task tests for sequential, hierarchical, missing-configuration, and cross-task JSON output.

Changes

JSON output API

Layer / File(s) Summary
JSON output accessors
lib/crewai/src/crewai/crews/crew_output.py, lib/crewai/src/crewai/tasks/task_output.py
Crew output exposes json_output(), while task output exposes json_output as a property and retains its JSON-format validation.
Task JSON output tests
lib/crewai/tests/test_task.py
Task tests now read result.json_output across sequential, hierarchical, missing-configuration, and cross-task scenarios.

Suggested reviewers: greysonlalonde

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: renaming the json property to json_output to fix a BaseModel conflict.
Description check ✅ Passed The description is directly related to the changeset and accurately summarizes the API rename and test updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant