Skip to content

fix: handle cherry-pick edge cases after AI conflict resolution#1045

Merged
myakove merged 2 commits intomainfrom
fix/issue-1043-1044-cherry-pick-ai-edge-cases
Mar 18, 2026
Merged

fix: handle cherry-pick edge cases after AI conflict resolution#1045
myakove merged 2 commits intomainfrom
fix/issue-1043-1044-cherry-pick-ai-edge-cases

Conversation

@myakove
Copy link
Copy Markdown
Collaborator

@myakove myakove commented Mar 18, 2026

Summary

  • Check CHERRY_PICK_HEAD before running --continue to handle auto-completed cherry-picks (e.g. modify/delete conflicts)
  • Handle empty cherry-pick result with --allow-empty commit when AI resolution produces no changes vs target branch
  • Add --label flags to gh pr create to prevent auto-verify/auto-merge race condition on AI-resolved cherry-pick PRs
  • Add ai-resolved-conflicts guard in set_pull_request_automerge() with active disable_automerge when already enabled
  • Return False for unexpected rev-parse errors instead of silently proceeding

Test plan

  • New test test_cherry_pick_ai_resolves_modify_delete_conflict validates auto-complete scenario
  • New test test_cherry_pick_ai_resolves_empty_cherry_pick validates empty commit fallback
  • Updated test_cherry_pick_ai_resolves_conflicts verifies labels in gh pr create command
  • Full test suite passes (1436 tests, 90.22% coverage)

Closes #1043
Closes #1044

Summary by CodeRabbit

  • New Features

    • Cherry-pick pull requests now include appropriate labels for better tracking and organization.
  • Improvements

    • Enhanced handling of AI-resolved conflicts in automated cherry-pick operations.
    • Auto-merge now prevents activation for cherry-picks containing resolved conflicts.

- Check CHERRY_PICK_HEAD before running --continue to handle
  auto-completed cherry-picks (e.g. modify/delete conflicts)
- Handle empty cherry-pick result with --allow-empty commit
- Add --label flags to gh pr create to prevent auto-verify/auto-merge
  race condition on AI-resolved cherry-pick PRs
- Add ai-resolved-conflicts guard in set_pull_request_automerge()
  with active disable_automerge when already enabled
- Return False for unexpected rev-parse errors instead of proceeding

Closes #1043
Closes #1044
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 18, 2026

Warning

Rate limit exceeded

@myakove has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 0 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5404765d-2e74-4bbb-841c-504ccb476ae5

📥 Commits

Reviewing files that changed from the base of the PR and between 4338ce4 and cab38fd.

📒 Files selected for processing (1)
  • webhook_server/libs/handlers/pull_request_handler.py

Walkthrough

The PR adds guard logic to prevent auto-merge of AI-resolved cherry-pick PRs and implements empty cherry-pick handling. It shifts label application from post-creation to PR creation time to eliminate race conditions during webhook processing.

Changes

Cohort / File(s) Summary
Auto-merge Guard
webhook_server/libs/handlers/pull_request_handler.py
Added early-return guard in set_pull_request_automerge() that disables auto-merge (if enabled) when ai-resolved-conflicts label is present, preventing auto-merge of cherry-pick PRs that require manual review.
Cherry-pick Flow Enhancement
webhook_server/libs/handlers/runner_handler.py
Enhanced cherry-pick resolution to capture CHERRY_PICK_HEAD return code and error output; handles empty cherry-picks with --allow-empty commits; adds validation guard to abort if CHERRY_PICK_HEAD returns unexpected errors; shifts label application to PR creation time by computing dynamic --label flags for gh pr create instead of post-creation via to_thread.
Test Updates
webhook_server/tests/test_runner_handler.py
Removed mock_to_thread binding for asyncio.to_thread; updated PR creation assertions to validate that labels (cherry-picked, ai-resolved-conflicts) are included directly in the gh pr create command string rather than added post-creation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Why: The changes touch multiple interdependent components (PR handler guard, runner handler cherry-pick flow, test assertions) and require understanding the race condition context. The modifications are cohesive but involve error code validation, conditional flag construction, and test assertion restructuring across three files.

Possibly related issues

Possibly related PRs

Suggested labels

size/M, branch-main, can-be-merged

Suggested reviewers

  • rnetser
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: handling cherry-pick edge cases after AI conflict resolution, which is the core purpose of the PR.
Linked Issues check ✅ Passed The PR fully addresses both linked issues: handles empty cherry-pick with --allow-empty [#1043], adds labels at PR creation and guards automerge [#1044].
Out of Scope Changes check ✅ Passed All changes are directly scoped to the two linked issues: cherry-pick edge case handling, label management, and automerge guards—no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-1043-1044-cherry-pick-ai-edge-cases
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@myakove-bot
Copy link
Copy Markdown
Collaborator

Report bugs in Issues

Welcome! 🎉

This pull request will be automatically processed with the following features:

🔄 Automatic Actions

  • Reviewer Assignment: Reviewers are automatically assigned based on the OWNERS file in the repository root
  • Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are automatically applied based on changes
  • Issue Creation: Disabled for this repository
  • Pre-commit Checks: pre-commit runs automatically if .pre-commit-config.yaml exists
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified
  • Labels: All label categories are enabled (default configuration)

📋 Available Commands

PR Status Management

  • /wip - Mark PR as work in progress (adds WIP: prefix to title)
  • /wip cancel - Remove work in progress status
  • /hold - Block PR merging (approvers only)
  • /hold cancel - Unblock PR merging
  • /verified - Mark PR as verified
  • /verified cancel - Remove verification status
  • /reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)
  • /regenerate-welcome - Regenerate this welcome message

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /automerge - Enable automatic merging when all requirements are met (maintainers and approvers only)
  • /assign-reviewers - Assign reviewers based on OWNERS file
  • /assign-reviewer @username - Assign specific reviewer
  • /check-can-merge - Check if PR meets merge requirements

Testing & Validation

  • /retest tox - Run Python test suite with tox
  • /retest build-container - Rebuild and test container image
  • /retest python-module-install - Test Python package installation
  • /retest pre-commit - Run pre-commit hooks and checks
  • /retest conventional-title - Validate commit message format
  • /retest all - Run all available tests

Container Operations

  • /build-and-push-container - Build and push container image (tagged with PR number)
    • Supports additional build arguments: /build-and-push-container --build-arg KEY=value

Cherry-pick Operations

  • /cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
    • Multiple branches: /cherry-pick branch1 branch2 branch3

Label Management

  • /<label-name> - Add a label to the PR
  • /<label-name> cancel - Remove a label from the PR

✅ Merge Requirements

This PR will be automatically approved when the following conditions are met:

  1. Approval: /approve from at least one approver
  2. LGTM Count: Minimum 1 /lgtm from reviewers
  3. Status Checks: All required status checks must pass
  4. No Blockers: No wip, hold, has-conflicts labels and PR must be mergeable (no conflicts)
  5. Verified: PR must be marked as verified

📊 Review Process

Approvers and Reviewers

Approvers:

  • myakove
  • rnetser

Reviewers:

  • myakove
  • rnetser
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
  • automerge

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is automatically removed on each new commit
  • Cherry-picking: Cherry-pick labels are processed when the PR is merged
  • Container Builds: Container images are automatically tagged with the PR number
  • Permission Levels: Some commands require approver permissions
  • Auto-verified Users: Certain users have automatic verification and merge privileges

For more information, please refer to the project documentation or contact the maintainers.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@webhook_server/libs/handlers/pull_request_handler.py`:
- Around line 917-920: The current except block logs only the exception message
using self.logger.error and thus loses traceback; update the except handling
around the auto-merge disable code to call
self.logger.exception(f"{self.log_prefix} Failed to disable auto-merge for
AI-resolved cherry-pick") (or alternately self.logger.error(..., exc_info=True))
so the full stack trace is preserved—replace the existing self.logger.error(...)
in that except Exception as exp block accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0375aa26-ebb4-45b0-980c-32617597dc93

📥 Commits

Reviewing files that changed from the base of the PR and between 88ffe55 and 4338ce4.

📒 Files selected for processing (3)
  • webhook_server/libs/handlers/pull_request_handler.py
  • webhook_server/libs/handlers/runner_handler.py
  • webhook_server/tests/test_runner_handler.py

Comment thread webhook_server/libs/handlers/pull_request_handler.py Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Mar 18, 2026
Per CLAUDE.md convention, use logger.exception() instead of
logger.error() to preserve full traceback in logs.
@myakove myakove merged commit f392601 into main Mar 18, 2026
7 of 9 checks passed
@myakove myakove deleted the fix/issue-1043-1044-cherry-pick-ai-edge-cases branch March 18, 2026 11:15
@myakove-bot
Copy link
Copy Markdown
Collaborator

New container for ghcr.io/myk-org/github-webhook-server:latest published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants