Skip to content

fix: retry push_files on concurrent branch updates#2622

Open
advancedresearcharray wants to merge 1 commit into
github:mainfrom
advancedresearcharray:fix/push-files-ref-update-retry-2481
Open

fix: retry push_files on concurrent branch updates#2622
advancedresearcharray wants to merge 1 commit into
github:mainfrom
advancedresearcharray:fix/push-files-ref-update-retry-2481

Conversation

@advancedresearcharray
Copy link
Copy Markdown

@advancedresearcharray advancedresearcharray commented Jun 6, 2026

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

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

Closes #2481

@advancedresearcharray advancedresearcharray requested a review from a team as a code owner June 6, 2026 06:11
@advancedresearcharray advancedresearcharray force-pushed the fix/push-files-ref-update-retry-2481 branch from 7276459 to 27178da Compare June 6, 2026 17:07
push_files used a read-modify-write sequence without retrying when UpdateRef
failed with a non-fast-forward conflict. During rapid multi-file pushes this
left orphaned commits and intermittent failures. Retry with the latest ref
and accept flexible files argument encodings from MCP hosts.

Closes github#2481
@advancedresearcharray
Copy link
Copy Markdown
Author

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

@advancedresearcharray advancedresearcharray force-pushed the fix/push-files-ref-update-retry-2481 branch from 27178da to 1983ac7 Compare June 6, 2026 17:10
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.

Intermittent commit/push failures when using GitHub MCP connector for file operations and branch management, via Grok official Connector

1 participant