Skip to content

fix: read profile manifests as utf-8 on Windows#40

Open
kodroi wants to merge 1 commit intoverygoodplugins:mainfrom
kodroi:fix/windows-utf8-profile-reading
Open

fix: read profile manifests as utf-8 on Windows#40
kodroi wants to merge 1 commit intoverygoodplugins:mainfrom
kodroi:fix/windows-utf8-profile-reading

Conversation

@kodroi
Copy link
Copy Markdown

@kodroi kodroi commented Apr 28, 2026

Summary

Windows profile reads now treat Stream Deck profile and page manifests as UTF-8, which stops streamdeck_read_profiles from crashing when a manifest contains emoji or other non-ASCII text.

The change keeps encoding decisions in the existing JSON helper layer by making manifest reads and atomic writes explicit about UTF-8 instead of inheriting the process codepage.

The regression test writes a real UTF-8 page manifest with "pastedText": "👍" and verifies both list_profiles() and read_page() can load it.

Closes #39.

Testing

  • uv run pytest tests\\test_profile_manager.py -k utf8 -q
  • uv run ruff check tests\\test_profile_manager.py profile_manager.py

Closes verygoodplugins#39.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 28, 2026 13:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes Windows crashes when reading Stream Deck profile/page manifests containing non-ASCII (e.g., emoji) by forcing JSON reads/writes to use UTF-8 in the shared helper layer, and adds a regression test covering UTF-8 emoji content in a page manifest.

Changes:

  • Read JSON manifests with Path.read_text(encoding="utf-8") in the JSON loader.
  • Write JSON manifests atomically with Path.write_text(..., encoding="utf-8").
  • Add a regression test that writes a UTF-8 page manifest containing "pastedText": "👍" and verifies list_profiles() + read_page() can load it.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/test_profile_manager.py Ensures test fixtures and new regression test write UTF-8 JSON and validates emoji survives a full load path.
profile_manager.py Makes JSON load/atomic write explicitly UTF-8 to avoid Windows codepage-dependent decoding/encoding.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"AppIdentifier": "*",
"Device": {"Model": "20GBA9901", "UUID": "@(1)"},
"Name": "UTF-8 Profile",
"Pages": {"Current": page_uuid, "Default": None, "Pages": []},
Comment on lines +1389 to +1396
"0,0": {
"ActionID": "action-open",
"Name": "Thumbs up",
"Settings": {"pastedText": "👍"},
"State": 0,
"States": [{}],
"UUID": "com.elgato.streamdeck.system.text",
}
@jack-arturo
Copy link
Copy Markdown
Member

@copilot apply changes based on the comments in this thread

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.

streamdeck_read_profiles fails on Windows with UTF-8 profile/page manifests

3 participants