Skip to content

Bug Report: UnicodeEncodeError on Windows when saving traces #30

Description

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

  1. Run on Windows with default console (cp1252 encoding)
  2. Execute: langsmith-fetch traces ./output --limit 1
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions