fix(git): raise error on invalid branch type; normalize git_log output format#4484
Open
isheng-eqi wants to merge 2 commits into
Open
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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