Bug Report: UnicodeEncodeError on Windows when saving traces
Summary
langsmith-fetch traces fails with UnicodeEncodeError on Windows when printing success messages to console, even though traces are successfully saved.
Environment
- OS: Windows 11 (Build 26200.7462)
- Python: 3.13.2544.0
- langsmith-fetch: 0.3.1
- Console encoding: cp1252 (Windows default)
Command
uv run langsmith-fetch traces ./traces --limit 2 --no-progress
Error
UnicodeEncodeError: 'charmap' codec can't encode character '\u2713' in position 2: character maps to <undefined>
in "C:\Program Files\WindowsApps\...\Lib\encodings\cp1252.py", line 19, in encode
Error location: langsmith_cli/cli.py, line 833
click.echo(f" \u2713 Saved {trace_id} to {safe_filename} ({summary})")
Issue
The checkmark character \u2713 (✓) cannot be encoded in Windows cp1252 encoding when writing to console.
Impact
- Traces are successfully fetched and saved despite the error
- Error appears cosmetic but exits with code 1, which may break CI/CD pipelines
- The
--no-progress flag does not prevent this error
Workaround
None currently - users must ignore the error messages.
Suggested Fix
Use ASCII-safe characters or handle encoding errors gracefully:
# Option 1: ASCII fallback
try:
click.echo(f" \u2713 Saved {trace_id} to {safe_filename} ({summary})")
except UnicodeEncodeError:
click.echo(f" Saved {trace_id} to {safe_filename} ({summary})")
# Option 2: Use click's color support which handles encoding
click.secho(f" Saved {trace_id} to {safe_filename} ({summary})", fg='green')
# Option 3: Detect Windows and use ASCII
import sys
checkmark = "\u2713" if sys.platform != "win32" else "✓" # Will use fallback
Reproduction
- Run on Windows with default console (cp1252 encoding)
- Execute:
langsmith-fetch traces ./output --limit 1
- Observe error despite successful trace save
Expected Behavior
Command should complete successfully (exit code 0) with appropriate console output.
Actual Behavior
Command exits with code 1 due to Unicode encoding error, even though traces are saved successfully.
Bug Report: UnicodeEncodeError on Windows when saving traces
Summary
langsmith-fetch tracesfails withUnicodeEncodeErroron Windows when printing success messages to console, even though traces are successfully saved.Environment
Command
Error
Error location:
langsmith_cli/cli.py, line 833Issue
The checkmark character
\u2713(✓) cannot be encoded in Windows cp1252 encoding when writing to console.Impact
--no-progressflag does not prevent this errorWorkaround
None currently - users must ignore the error messages.
Suggested Fix
Use ASCII-safe characters or handle encoding errors gracefully:
Reproduction
langsmith-fetch traces ./output --limit 1Expected Behavior
Command should complete successfully (exit code 0) with appropriate console output.
Actual Behavior
Command exits with code 1 due to Unicode encoding error, even though traces are saved successfully.