-
Notifications
You must be signed in to change notification settings - Fork 28
[feat] Check if auto PR reviews are enabled for a given owner #1285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🚨 Sentry detected 1 potential issue in your recent changes 🚨Lower risk findings
Did you find this useful? React with a 👍 or 👎 |
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. 📢 Thoughts on this report? Let us know! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #1285 +/- ##
=======================================
Coverage 96.35% 96.35%
=======================================
Files 488 488
Lines 16919 16932 +13
=======================================
+ Hits 16302 16315 +13
Misses 617 617
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@codecov-ai-reviewer test |
On it! Codecov is generating unit tests for this PR. |
Co-authored-by: codecov-ai[bot] <156709835+codecov-ai[bot]@users.noreply.github.com> Co-authored-by: Rohit <rohit.vinnakota@sentry.io>
@codecov-ai-reviewer review |
On it! We are reviewing the PR and will provide feedback shortly. |
webhook_handlers/views/github.py
Outdated
def pull_request(self, request, *args, **kwargs): | ||
if ( | ||
request.META.get(GitHubHTTPHeaders.HOOK_INSTALLATION_TARGET_ID, "") | ||
== AI_FEATURES_GH_APP_ID | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string comparison with AI_FEATURES_GH_APP_ID
could be unsafe if the types don't match. Consider adding type conversion to ensure robust comparison. Also, consider extracting this check into a helper method for better readability and reusability.
def pull_request(self, request, *args, **kwargs): | |
if ( | |
request.META.get(GitHubHTTPHeaders.HOOK_INSTALLATION_TARGET_ID, "") | |
== AI_FEATURES_GH_APP_ID | |
): | |
def _is_ai_features_request(self, request): | |
target_id = request.META.get(GitHubHTTPHeaders.HOOK_INSTALLATION_TARGET_ID, '') | |
return str(target_id) == str(AI_FEATURES_GH_APP_ID) | |
def pull_request(self, request, *args, **kwargs): | |
if self._is_ai_features_request(request): | |
return self.check_codecov_ai_auto_enabled_reviews(request) |
9f86340
to
459bbbf
Compare
On it! We are reviewing the PR and will provide feedback shortly. |
PR Description: Here's a detailed analysis of this pull request: PurposeThis PR implements a webhook-based mechanism to check if AI-powered code reviews should be automatically triggered for GitHub pull requests. It's part of a larger AI features integration system that appears to be controlled by a separate GitHub App installation. Key Technical Changes
Architecture Decisions
Dependencies and Interactions
Risk Considerations
Notable Implementation Details
This PR appears to be laying the groundwork for a larger AI-powered code review feature while maintaining a clean separation of concerns and following existing architectural patterns. The implementation is well-tested and includes appropriate error handling and validation. |
service_id=request.data["repository"]["owner"]["id"], | ||
) | ||
|
||
auto_review_enabled = org.yaml.get("ai_pr_review", {}).get("auto_review", False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for later: think whether you want to use the full yaml vs the org yaml or any variant
Purpose/Motivation
What is the feature? Why is this being done?
This will be consumed in shelter. Forwarded pull request webhooks from codecov AI will check if the user has configured an auto-review setting for their org. If they have, the resulting response will be used upstream to kick off a review PR flow in seer.
Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.