openai / openai/codex

plugin-creator sample script crashes on non-ASCII marketplace.json under non-UTF-8 locale (missing encoding="utf-8")

Open Beginner friendly
#41,026 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI skills windows-os
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

Description

codex-rs/skills/src/assets/samples/plugin-creator/scripts/create_basic_plugin.py opens files without specifying encoding="utf-8":

def load_json(path: Path) -> dict[str, Any]:
    with path.open() as handle:
        return json.load(handle)

(also the two path.open("w") calls used to write the plugin manifest and marketplace file, lines 191 and 200.)

Without an explicit encoding, Python (below the PEP 686 UTF-8-by-default cutover) uses locale.getpreferredencoding() for text I/O. On a non-UTF-8-locale Windows install (e.g. Chinese/Japanese/Korean Windows, where the system locale is commonly cp936/cp932/cp949), this is not UTF-8.

load_json() reads ~/.agents/plugins/marketplace.json, which is the file the real Rust product maintains (codex-rs/core-plugins/src/marketplace.rs:1079, via serde_json::to_string_pretty, which emits raw UTF-8 for non-ASCII strings, not \uXXXX-escaped). As soon as any plugin's displayName (or any other field) contains a non-ASCII character — an accented name, CJK text, an emoji — running this sample script on a non-UTF-8-locale Windows machine crashes with UnicodeDecodeError instead of working normally.

Steps to reproduce
import json, tempfile
from pathlib import Path
from create_basic_plugin import load_json

p = Path(tempfile.mkdtemp()) / "marketplace.json"
# Simulate a marketplace.json as written by the real Rust app (raw UTF-8, not \uXXXX-escaped)
p.write_text(
    json.dumps({"name": "personal", "interface": {"displayName": "café-tools ☕"}}, ensure_ascii=False),
    encoding="utf-8",
)
load_json(p)

On a machine whose locale encoding is cp936 (verified via locale.getencoding()):

UnicodeDecodeError: 'gbk' codec can't decode byte 0x95 in position 65: illegal multibyte sequence
Expected behavior

Reading/writing a UTF-8 JSON file (which per RFC 8259 is what all JSON is) should work regardless of the host's locale.

Actual behavior

UnicodeDecodeError on non-UTF-8-locale systems as soon as the JSON contains non-ASCII text.

Environment
  • Commit: 7c37479 (main, 2026-08-27), Python 3.14, Windows 11, locale cp936
  • File: codex-rs/skills/src/assets/samples/plugin-creator/scripts/create_basic_plugin.py:100,191,200
  • Note: codex-rs/skills/tests/test_plugin_creator.py exists and writes fixtures with encoding="utf-8", but always via json.dumps(payload) (default ensure_ascii=True), which produces pure-ASCII output and therefore never exercises this path — that's likely why the existing test suite hasn't caught it.
Suggested fix
 def load_json(path: Path) -> dict[str, Any]:
-    with path.open() as handle:
+    with path.open(encoding="utf-8") as handle:
         return json.load(handle)

and the same encoding="utf-8" addition to the two path.open("w") calls at lines 191 and 200.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with codex-rs/skills/src/assets/samples/plugin-creator/scripts/create_basic_plugin.py and inspect load_json plus the two path.open("w") calls around lines 191 and 200. Run codex-rs/skills/tests/test_plugin_creator.py, adding or adapting a non-ASCII fixture so the test exercises UTF-8 input and output; done means the sample works independently of the host locale.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.