fix: use webhook payload SHAs in list_changed_files to avoid race condition#1107
fix: use webhook payload SHAs in list_changed_files to avoid race condition#1107myakove wants to merge 2 commits into
Conversation
Code Review by Qodo
Context used 1.
|
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Container Operations
Cherry-pick Operations
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
AI Features
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
…dition - Replace live PyGithub API calls with webhook payload SHAs for pull_request events - Fall back to API for non-PR events (issue_comment, check_run, etc.) - Store pr_base_sha/pr_head_sha on GithubWebhook instance during process() - Remove pull_request parameter from initialize() and list_changed_files() - Add symmetric guards for both base and head SHA validation Closes #1096
7ff7d45 to
92438ea
Compare
|
Code review by qodo was updated up to the latest commit 92438ea |
|
@qodo-code-review[bot] The following review comments were reviewed and a decision was made:
|
Declare pr_base_sha and pr_head_sha in __init__() with empty string defaults so mypy strict mode has clear type declarations. Remove redundant inline annotations in process() since the class-level ones cover typing.
|
Code review by qodo was updated up to the latest commit 5a40c0f |
|
@qodo-code-review[bot] The following review comments were reviewed and a decision was made:
|
PR Summary by Qodo
Fix changed-files diff race by using webhook payload base/head SHAs
🐞 Bug fix🧪 Tests🕐 20-40 MinutesWalkthroughs
User Description
Summary
Replace live PyGithub API calls with webhook payload SHAs in
list_changed_files()to eliminate a race condition where base branch receives new commits between clone and API call.pull_requestevents (no race condition)pr_base_sha/pr_head_shaon GithubWebhook instance duringprocess()pull_requestparameter frominitialize()andlist_changed_files()Closes #1096
AI Description
Diagram
graph TD A["GitHub webhook payload"] --> B["GithubWebhook.process"] --> C["Store PR base/head SHAs"] --> D[("Local clone")] --> E["OwnersFileHandler.list_changed_files"] --> F["git diff --name-only"] B --> G["PullRequest API (fallback)"] --> CHigh-Level Assessment
Using webhook payload SHAs for pull_request events is the most reliable way to keep the local clone and diff base/head aligned and eliminate the observed race. Alternatives like always querying live PR/base refs or diffing against the current base branch would reintroduce timing drift; passing SHAs through additional parameters instead of storing on the per-request GithubWebhook instance would add plumbing without changing the core correctness.
File Changes
Bug fix (2)
Tests (2)