Skip to content

process.run raises UnicodeEncodeError for an input string with a lone surrogate #760

Open

Description

@antonwolfy

run in dokimi/dokimi/process.py:190 encodes a string input with input.encode("utf-8") before it spawns the child (lines 746 and 777 do the same in the other entry points). A prompt built from a question or an artifact text with a \ud800 JSON escape reaches it. Repro: process.run(['cat'], input=json.loads('"n\\ud800"'), timeout=5, env=process.Env.inherit()) raises UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800' in position N: surrogates not allowed at process.py:190. It is not a hash, so the fix is a decision: refuse the input with a message where the prompt is built, or encode with errors='replace' for the child's stdin (a lone surrogate has no UTF-8 form, so surrogatepass would send invalid UTF-8 to the child). Only line 190 was run; 746 and 777 were read.

Found while fixing #720. The fix's PR is #761.

Activity

  1. self-assigned this
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions