github-mcp-server icon indicating copy to clipboard operation
github-mcp-server copied to clipboard

fix: retry push_files on concurrent branch updates

Open advancedresearcharray opened this issue 5 months ago • 2 comments

Summary

  • Add retry logic to push_files when GitHub rejects a ref update with a non-fast-forward conflict, which occurs during rapid sequential pushes to the same branch
  • Normalize the files argument from multiple MCP host encodings ([]any, typed slices, JSON strings)
  • Extract git push helpers with regression tests covering conflict retry and argument parsing

Problem

Issue #2481 reports intermittent commit/push failures during heavy multi-file refactoring sessions. The push_files tool performed a read-modify-write sequence (get ref → create tree → create commit → update ref) without handling concurrent branch updates. When another push landed between the initial ref read and UpdateRef, GitHub returned a 422 non-fast-forward error, leaving an orphaned commit and a failed push.

Some MCP hosts also send the files parameter in encodings that failed the strict []any type assertion, producing JSON parsing errors.

Test plan

  • [x] go test ./pkg/github/...
  • [x] New unit test verifies retry succeeds after initial 422 on UpdateRef
  • [x] New unit tests verify flexible files parameter parsing

Closes #2481

advancedresearcharray avatar Jun 06 '26 06:06 advancedresearcharray

Rebased onto latest main and force-pushed (27178da → 1983ac7). go test ./pkg/github/... -run Push passes locally on Go 1.25.

advancedresearcharray avatar Jun 06 '26 17:06 advancedresearcharray

Merge-ready check-in

This PR looks ready for maintainer review/merge when you have a moment.

  • Change: fix: retry push_files on concurrent branch updates
  • CI: green / passing
  • Review: REVIEW_REQUIRED (mergeable: MERGEABLE)

Happy to rebase or address any remaining feedback. Thanks for maintaining the project.

advancedresearcharray avatar Jun 12 '26 17:06 advancedresearcharray