Skip to content

fix: handle windows hook unicode prompts - #1316

Open
222twotwotwo wants to merge 1 commit into
oceanbase:masterfrom
222twotwotwo:fix/windows-hook-unicode-prompts
Open

fix: handle windows hook unicode prompts#1316
222twotwotwo wants to merge 1 commit into
oceanbase:masterfrom
222twotwotwo:fix/windows-hook-unicode-prompts

Conversation

@222twotwotwo

Copy link
Copy Markdown

Which issue or RFC does this PR close?

Closes #1305

Rationale for this change

On Windows, the Claude Code and Codex hook scripts could read stdin using the local console encoding instead of UTF-8. That corrupted non-ASCII prompts and could produce lone surrogate characters. The server then failed while rendering the 422 validation response because the raw invalid input was included in the returned error details.

What changes are included in this PR?

The Claude Code and Codex hook scripts now read JSON payloads from sys.stdin.buffer and decode them as UTF-8 before parsing.
The server’s RequestValidationError handler now removes the raw input field from validation errors before returning the 422 response.
Regression tests were added for UTF-8 stdin handling on Windows and for surrogate-safe validation responses.

Are there any user-facing changes?

Yes. Windows users submitting non-ASCII prompts through Claude Code or Codex hooks should no longer see corrupted prompts or broken validation responses.
The API still returns 422 for invalid requests, but it no longer echoes the raw invalid input in the error details.

How was this change tested?

  • pytest tests/test_server.py -q -k "invalid_request_without_input_field or unicode_surrogates_without_crashing"
  • pytest tests/claude_code_plugin/test_hook.py tests/codex_plugin/test_recall.py -q

AI usage statement

AI tools were used to implement and verify this change.

@CLAassistant

CLAassistant commented Aug 22, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

[Bug] Windows hooks corrupt UTF-8 prompts and crash validation error handling

2 participants