crewai create flow writes a project file the platform default codec cannot encode

オープン
#9,689 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@shengzhaowei がすでに取り組んでいます。

2026年11月24日 から。

  • #9688 @DZH166 による — マージされずにクローズ
  • #9701 @shengzhaowei による — オープン

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
cli

調査の方向性

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時間
マージ済み PR(30日)
180

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

crewAIInc/crewAI のほかの issue

crewAIInc/crewAI の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。