fix(events): prevent UnicodeEncodeError crash on non-UTF-8 consoles#6522
Open
Aakash326 wants to merge 1 commit into
Open
fix(events): prevent UnicodeEncodeError crash on non-UTF-8 consoles#6522Aakash326 wants to merge 1 commit into
Aakash326 wants to merge 1 commit into
Conversation
ConsoleFormatter builds a rich.Console around sys.stdout without guarding its encoding. On Windows terminals using a legacy codepage (cp1252), printing emoji panel titles (e.g. Flow Started, Flow Method Running) raises UnicodeEncodeError inside the sync event handlers. The event bus swallows the exception and prints an error line instead, so every Flow event silently fails to render and spams "[CrewAIEventsBus] Sync handler error ..." for the entire run. This is the same root cause behind several previously closed issues (crewAIInc#3062, crewAIInc#2715, crewAIInc#2708, crewAIInc#823, crewAIInc#772, crewAIInc#755, crewAIInc#713, crewAIInc#665, crewAIInc#603) - each was patched around a specific emoji/message rather than fixed at the source, so it keeps recurring as new emoji panels are added. Reconfigure the underlying stream to use errors="replace" so unencodable characters degrade to "?" instead of crashing. Co-authored-by: Cursor <cursoragent@cursor.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughConsoleFormatter now best-effort configures supported console streams with ChangesConsole encoding handling
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows terminals using a legacy codepage (cp1252), printing emoji panel
titles (e.g. "🌊 Flow Started", "🔄 Flow Method Running") raises
UnicodeEncodeError inside ConsoleFormatter's sync event handlers. The event
bus swallows the exception and prints an error line instead, so every Flow
event silently fails to render and spams
"[CrewAIEventsBus] Sync handler error ..." for the whole run.
This is the same root cause behind several previously closed issues
(#3062, #2715, #2708, #823, #772, #755, #713, #665, #603) — each was patched
around a specific emoji/message rather than fixed at the source, so it keeps
recurring whenever a new emoji panel is added.
Fix: reconfigure the console's underlying stream to use errors="replace" on
init, so unencodable characters degrade to "?" instead of crashing.
Reproduced locally on Windows (cp1252 console) with a simple Flow —
confirmed crash before the fix, clean output after. Added regression test
covering both the stream reconfiguration and an emoji panel print against a
cp1252-encoded stream.