Skip to content

fix(git): handle non-UTF-8 bytes in git_show#4532

Open
dev-willbird1936 wants to merge 1 commit into
modelcontextprotocol:mainfrom
dev-willbird1936:fix/git-show-binary-safe
Open

fix(git): handle non-UTF-8 bytes in git_show#4532
dev-willbird1936 wants to merge 1 commit into
modelcontextprotocol:mainfrom
dev-willbird1936:fix/git-show-binary-safe

Conversation

@dev-willbird1936

Copy link
Copy Markdown

Description

Make the Git server's git_show robust to valid commits whose patch contains bytes that are not valid UTF-8. Decode replacement bytes instead of failing the complete result with UnicodeDecodeError.

Root cause

The Git server strictly decoded GitPython patch bytes as UTF-8. One invalid byte could discard the complete patch result, including otherwise useful commit metadata.

Testing

  • Focused git_show_handles_non_utf8_diff assertion passed.
  • uv run ruff check passed.
  • uv run pyright passed.
  • uv build passed.
  • The full Python module produced 44 passed test bodies plus 38 existing Windows fixture-teardown errors from open GitPython handles; this is not presented as a green full-suite result.
  • LLM-client integration was not exercised; tests call the Git server implementation directly.

This is an ordinary correctness/robustness fix, not a security report. Hosted POSIX CI is recommended to remove the Windows-only fixture teardown noise. Maintainer review remains pending.

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.

2 participants