Skip to content

Conversation

@victordibia
Copy link
Collaborator

@victordibia victordibia commented Mar 25, 2025

Why are these changes needed?

Add utf encoding to file reading.
Without this, a default system encoding will be used. On Windows machines this can default to any local encoding causing errors.

with open(
            os.path.join(os.path.abspath(os.path.dirname(__file__)), "page_script.js"), "rt", encoding="utf-8"
        ) as fh:

Related issue number

Closes #6093

Checks

@victordibia victordibia changed the title add utf encoding in websurfer read file - add utf encoding in websurfer read file Mar 25, 2025
@victordibia victordibia requested a review from afourney March 25, 2025 05:46
@codecov
Copy link

codecov bot commented Mar 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.75%. Comparing base (7047fb8) to head (aae3537).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6094   +/-   ##
=======================================
  Coverage   76.75%   76.75%           
=======================================
  Files         191      191           
  Lines       13226    13226           
=======================================
  Hits        10152    10152           
  Misses       3074     3074           
Flag Coverage Δ
unittests 76.75% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@victordibia victordibia requested a review from ekzhu March 25, 2025 06:23
@victordibia victordibia merged commit 9a05883 into main Mar 25, 2025
57 checks passed
@victordibia victordibia deleted the fix_encoding_websurfer branch March 25, 2025 16:01
Sean-Kenneth-Doherty added a commit to Sean-Kenneth-Doherty/autogen that referenced this pull request Jan 31, 2026
This follows up on issue microsoft#5566 and PR microsoft#6094 which fixed the same issue
in playwright_controller.py. The task_centric_memory module has similar
file operations without explicit encoding, which can cause
UnicodeDecodeError on non-English Windows systems (e.g., cp950, gbk).

Files fixed:
- chat_completion_client_recorder.py: session file read/write
- page_logger.py: hash file, call tree HTML, and page HTML writes

Without explicit encoding, Python uses the system default encoding which
varies by locale (cp950 for Traditional Chinese Windows, cp936 for
Simplified Chinese, etc.) and may fail to decode UTF-8 content.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: AutoGen Studio - Unclickable New Team, Session buttons

2 participants