Skip to content

fix: add explicit encoding="utf-8" to text-mode file I/O#784

Open
Ghraven wants to merge 1 commit into
apache:mainfrom
Ghraven:fix/add-encoding-text-file-io
Open

fix: add explicit encoding="utf-8" to text-mode file I/O#784
Ghraven wants to merge 1 commit into
apache:mainfrom
Ghraven:fix/add-encoding-text-file-io

Conversation

@Ghraven
Copy link
Copy Markdown

@Ghraven Ghraven commented May 20, 2026

What

Several text-mode open() calls in burr/ do not specify an encoding, so they fall back to the platform default (locale.getpreferredencoding()), which is cp1252 on Windows rather than UTF-8:

File Purpose
burr/cli/__main__.py read + write JSON test-case files
burr/testing/__init__.py read JSON test cases
burr/integrations/streamlit.py read JSONL tracking log
burr/tracking/server/run.py read bundled index.html at startup

Why it matters

JSON and JSONL are defined as UTF-8 (RFC 8259). On a non-UTF-8 platform, any non-ASCII content in tracked state, test cases, or the UI bundle would raise UnicodeDecodeError or be silently corrupted, even though the files are valid UTF-8.

Fix

Added encoding="utf-8" to each affected text-mode open() call. No behavior change on systems that already default to UTF-8, since UTF-8 is a strict superset of ASCII.

Verification

All four files still parse and import. The existing append-mode log handle in tracking/client.py already sets encoding="utf-8", so this aligns the rest of the file I/O with that convention. Happy to adjust scope if you would prefer these split up.

Several text-mode open() calls relied on the platform default encoding
(cp1252 on Windows) when reading/writing JSON test-case files, the
JSONL streamlit log, and the bundled index.html. JSON and JSONL are
UTF-8 per RFC 8259, so non-ASCII content could raise UnicodeDecodeError
or be corrupted on non-UTF-8 platforms. Pinning encoding="utf-8" makes
behavior consistent everywhere.
@github-actions github-actions Bot added area/tracking Telemetry, tracing, OpenTelemetry area/integrations External integrations (LLMs, frameworks) labels May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/integrations External integrations (LLMs, frameworks) area/tracking Telemetry, tracing, OpenTelemetry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant