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

Aperta
#9,689 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@shengzhaowei ci sta già lavorando.

Dal 24/11/2026.

  • #9688 di @DZH166 — chiusa senza merge
  • #9701 di @shengzhaowei — aperta

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
cli

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
61.2k
Fork
9.2k
Merge medio
1g 14h
PR unite (30g)
180

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di crewAIInc/crewAI

Tutte le issue di crewAIInc/crewAI

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.