Repository navigation
fix(git): raise error on invalid branch type; normalize git_log output format - #4484
isheng-eqi wants to merge 2 commits into
Conversation
…t format Two fixes in the git server: 1. git_branch: Invalid branch_type values (not 'local'/'remote'/'all') returned an error string that was silently treated as successful branch output. Now raises ValueError so the caller can properly report the error to the client. 2. git_log: The filtered (--since/--until) and unfiltered paths produced inconsistent output. The unfiltered path used !r (repr) formatting which adds quotes around values (e.g., Commit: 'abc123'), while the filtered path had no quotes. Both paths now use consistent plain formatting. Message field indentation normalized to 4 spaces in both paths.
2e2e51d to
012b468
Compare
|
Thank you for this pull request, and apologies for the long wait for a response. Since it was opened, the reference servers have been rebuilt for the 2026-07-28 MCP specification (#4857) and released as v2 (2.0.0 on npm for the TypeScript servers, 2026.10.19 on PyPI for the Python servers). The code this PR changes has been replaced, and the behavior it addresses has either been fixed in v2 or no longer exists in the same form. This is not a judgment on the change or on you; it's a consequence of the code it targets having been replaced. If the problem still happens on v2, please open a fresh issue with the version you're running and steps to reproduce. Note that this repository now accepts contributions as issues rather than pull requests from anyone but its maintainers; see This is part of the backlog triage in #4875. |
Summary
Two fixes in the git server.
Problem 1: Invalid branch_type silently succeeds
git_branchaccepted anybranch_typevalue via amatchdefault case that returned an error string (line 300). Since the caller treats all non-exception returns as successful output, an invalid type like"blah"would produce output"Invalid branch type: blah"— indistinguishable from a successful branch listing to the LLM consumer.Problem 2: git_log format inconsistency between code paths
The
git_logfunction has two paths:--since/--until):Commit: abc123(plain format)Commit: abc123(repr format with!r)This means the LLM sees different output formats depending on whether date filters are used, making it harder to parse. Also the
Message:prefix was inconsistent — the filtered path usedMessage:while the fix normalizes both to a 4-space indent for message lines.Changes
src/git/src/mcp_server_git/server.py(+5/-5):git_branch:return f"Invalid..."→raise ValueError(...)with descriptive message listing valid valuesgit_log: removed!rfrom unfiltered path; normalized message indentation to 4 spaces in both paths