Skip to content

fix: write trajectory exports as utf-8 - #14810

Merged
VascoSch92 merged 1 commit into
OpenHands:mainfrom
wgu9:fix-trajectory-export-utf8
Jun 16, 2026
Merged

VascoSch92 merged 1 commit into
OpenHands:mainfrom
wgu9:fix-trajectory-export-utf8

Conversation

@wgu9

@wgu9 wgu9 commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

HUMAN:
This PR makes trajectory exports explicitly write event and metadata JSON as UTF-8, so conversations with non-ASCII content export consistently on platforms whose default encoding is not UTF-8. The change is limited to the export write boundary and covered by a regression test that simulates a non-UTF-8 platform default.

  • A human has tested these changes.

Summary

  • Write trajectory export event_*.json files and meta.json with explicit UTF-8 encoding.
  • Add a regression test that simulates a non-UTF-8 platform default encoding and verifies exported metadata and event payloads decode as UTF-8.

Why

export_conversation() writes JSON files before zipping the trajectory. Without an explicit encoding, Python uses the platform default. On Windows-style defaults such as cp1252, metadata or event payloads containing non-ASCII characters can fail to write or produce inconsistent export bytes.

The exported trajectory is already consumed as UTF-8 by existing tests and clients, so the write boundary should use the same encoding explicitly.

Edge cases covered

  • Non-ASCII conversation metadata.
  • Non-ASCII event payloads.
  • Platform defaults that cannot encode emoji.
  • Existing empty-events export behavior.
  • Existing paginated event export behavior.
  • Existing conversation-not-found behavior.
  • Existing zip layout and filenames.
  • Existing JSON schema and API response type.

Validation

  • uv run --group test pytest tests/unit/app_server/test_live_status_app_conversation_service.py -q
  • uv run ruff format --check openhands/app_server/app_conversation/live_status_app_conversation_service.py tests/unit/app_server/test_live_status_app_conversation_service.py
  • uv run ruff check openhands/app_server/app_conversation/live_status_app_conversation_service.py tests/unit/app_server/test_live_status_app_conversation_service.py
  • git diff --check

@github-actions

Copy link
Copy Markdown
Contributor

👋 Thanks for opening this PR!

Your PR is marked for review. Can you confirm with a 👍 reaction on this comment or a reply that this PR is ready to review?

If no confirmation is received within 7 days, this PR will be converted back to a draft.

@github-actions github-actions Bot added the type: fix A bug fix label Jun 15, 2026
@wgu9
wgu9 force-pushed the fix-trajectory-export-utf8 branch from b7fcf6b to 401506d Compare June 15, 2026 01:32

@VascoSch92 VascoSch92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you :-)

@VascoSch92
VascoSch92 merged commit 88b55a8 into OpenHands:main Jun 16, 2026
48 of 49 checks passed
@openhands-release-bot openhands-release-bot Bot added the released: cloud-1.39.0 Shipped in cloud-1.39.0 label Jun 24, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in cloud-1.39.0.

@wgu9
wgu9 deleted the fix-trajectory-export-utf8 branch June 29, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released: cloud-1.39.0 Shipped in cloud-1.39.0 type: fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants