[BUG] ExperimentResults to_json uses locale encoding on Windows
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 58.8k
- Forks
- 8.5k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 109
Description
Description
ExperimentResults.to_json and compare_with_baseline open result files with the locale encoding. On Windows that is often cp1252, so UTF-8 identifiers and metadata raise UnicodeEncodeError. json.dump also has no default encoder, so datetime values in metadata raise TypeError.
Steps to Reproduce
from pathlib import Path
from crewai.experimental.evaluation.experiment.result import ExperimentResult, ExperimentResults
results = ExperimentResults(
[ExperimentResult(identifier="café", inputs={}, score=1, expected_score=1, passed=True)],
metadata={"note": "résumé"},
)
results.to_json(str(Path("out.json")))
Run with a cp1252 locale.
Expected behavior
Files are written and read as UTF-8. Non-JSON metadata values are stringified instead of crashing.
Screenshots/Code snippets
UnicodeEncodeError: 'charmap' codec can't encode character
Operating System
Windows 11
Python Version
3.12
crewAI Version
main
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.
Research direction
Start in crewai/experimental/evaluation/experiment/result.py, using the ExperimentResults.to_json and compare_with_baseline entry points shown in the report. Reproduce the case with a cp1252 locale and inspect how files and metadata are serialized. Done means UTF-8 reading and writing works for non-ASCII values, and non-JSON metadata values are stringified without crashing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100