crewai create flow writes a project file the platform default codec cannot encode
维护者通常 1 天内回复
评估
调研方向
The bug is in _create_python_flow() and process_file in lib/cli/src/crewai_cli/create_flow.py, which reads the template as UTF-8 but writes it with open(dst_file, "w") and no encoding. Compare with _create_declarative_flow, which uses write_text(content, encoding="utf-8"). Done means the generated tasks.yaml is valid UTF-8 under a non-UTF-8 locale, with a regression test. Pull request #9701 is already open against this issue, so check it before starting.
由索引模型根据 Issue 内容生成。
描述
Problem
_create_python_flow() in lib/cli/src/crewai_cli/create_flow.py renders the
flow template with process_file, which reads the template as UTF-8 and then
writes the result with the interpreter's locale encoding:
with open(src_file, "r", encoding="utf-8") as file: # read
content = file.read()
...
with open(dst_file, "w") as file: # write: locale encoding
file.write(content)
The templates it renders are UTF-8 and are not ASCII-only:
templates/flow/crews/content_crew/config/tasks.yaml line 45 contains an em
dash (U+2014). On any machine whose default text encoding is not UTF-8 — every
Windows install without the UTF-8 code-page beta (zh-CN is cp936, ja-JP cp932,
…), and any POSIX box under LANG=C — the scaffolded file is written in that
code page instead: the em dash becomes the two bytes a1 aa, which are not
valid UTF-8. So crewai create flow produces a project that the CLI itself
cannot read back:
$ python repro-2.py
locale.getpreferredencoding(False) = cp936
generated demo_flow\src\demo_flow\crews\content_crew\config\tasks.yaml: non-ASCII bytes ['0xa1', '0xaa']
reading it as UTF-8 -> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 1496: invalid start byte
EXPECTED: the generated file is valid UTF-8
ACTUAL: 'utf-8' codec can't decode byte 0xa1 in position 1496: invalid start byte
That file is the crew's tasks_config, loaded through
crewai.project.crew_base.load_yaml, which opens it with
encoding="utf-8" (lib/crewai/src/crewai/project/crew_base.py:391), so
crewai run in the freshly created project dies with
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 1496
before the flow starts. Note that the other writer in the same module —
_create_declarative_flow — already uses
dst_file.write_text(content, encoding="utf-8"), and
crewai_cli.utils.copy_assistant_instructions/write_env_file do the same; the
Python-flow template writer is the one path left on the locale default.
A PR with the one-line fix and a regression test is #9688.
- 主要语言
- Python
- 星标
- 61.2k
- 派生
- 9.2k
- 平均合并
- 1 天 14 小时
- 30 天内合并 PR
- 180
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
crewAIInc/crewAI 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
[FEATURE] Add Straitly as a native OpenAI-compatible LLM provider可能已有人在做 @HashimSyedUBC 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
[BUG] Native OpenAI sync streaming with response_model returns an empty string and emits no completed event when the parse is missing可能已有人在做 @basil-k-aji-dev 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
[BUG] Native Azure provider ignores the seed setting可能已有人在做 @basil-k-aji-dev 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
crewAIInc/crewAI#9787 · 1 条评论 ·
维护者通常 1 天内回复
-
[BUG] LiteLLM path reports 0 cached and reasoning tokens in the usage summary可能已有人在做 @basil-k-aji-dev 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
相似的 Issue
-
bug harness
难度 2/5 1-3 小时 新手友好度 72/100
mruangutai/harness#2687 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
modal-labs/modal-client#4158 ·
-
good first issue
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 72/100
The-Swarm-Corporation/swarms-rs#168 ·
维护者通常 1 天内回复
-
[BUG] SMTP listener now binds to EMAIL_PORT instead of 2525 since the gunicorn switch 5.0.3-ls373未关闭
难度 2/5 1-3 小时 新手友好度 72/100
linuxserver/docker-healthchecks#137 · 1 条评论 ·