Skip to content

fix(state): persist json checkpoints as utf-8 - #6858

Open
Ghraven wants to merge 1 commit into
crewAIInc:mainfrom
Ghraven:fix/json-provider-utf8
Open

fix(state): persist json checkpoints as utf-8#6858
Ghraven wants to merge 1 commit into
crewAIInc:mainfrom
Ghraven:fix/json-provider-utf8

Conversation

@Ghraven

@Ghraven Ghraven commented Aug 7, 2026

Copy link
Copy Markdown

Problem

JsonProvider writes and reads checkpoint JSON using the platform default text encoding. On systems where the default encoding is not UTF-8, checkpoint payloads containing non-ASCII state can fail to persist or restore consistently.

Before / after

Before, sync and async checkpoint reads/writes relied on the process/platform default encoding.

After, both paths use encoding="utf-8" explicitly for checkpoint files, matching the JSON/state portability expectation.

Verification

  • uv run pytest lib/crewai/tests/test_checkpoint.py::TestJsonProviderFork::test_checkpoint_round_trips_utf8_text lib/crewai/tests/test_checkpoint.py::TestJsonProviderFork::test_acheckpoint_round_trips_utf8_text -n 0 --allowed-hosts=127.0.0.1,localhost
  • git diff --check

I also tried the broader TestJsonProviderFork slice locally on Windows. The new UTF-8 tests passed, but the broader slice still hits existing Windows-local assumptions unrelated to this change: two tests assert POSIX-style /main/ and /fork/exp1/ separators, and one teardown encountered a locked temporary SQLite file.

@coderabbitai

coderabbitai Bot commented Aug 7, 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: 13fdaa13-0ef1-4e54-97a5-312b1e6f9514

📥 Commits

Reviewing files that changed from the base of the PR and between 03e3724 and ad4dbb4.

📒 Files selected for processing (2)
  • lib/crewai/src/crewai/state/provider/json_provider.py
  • lib/crewai/tests/test_checkpoint.py

📝 Walkthrough

Walkthrough

JsonProvider now uses explicit UTF-8 encoding for synchronous and asynchronous checkpoint file operations. Tests verify exact round-trip preservation for JSON payloads containing non-ASCII text.

Changes

UTF-8 checkpoint persistence

Layer / File(s) Summary
Encoding behavior and round-trip validation
lib/crewai/src/crewai/state/provider/json_provider.py, lib/crewai/tests/test_checkpoint.py
Synchronous and asynchronous checkpoint reads and writes now use UTF-8. Tests verify exact restoration of UTF-8 JSON payloads.
Suggested reviewers: greysonlalonde
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the UTF-8 checkpoint persistence fix.
Description check ✅ Passed The description explains the encoding problem, the synchronous and asynchronous changes, and the related verification.
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