-
Notifications
You must be signed in to change notification settings - Fork 124
[Integration][SonarQube] Bug handling of live events in sonarqube #1804
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
base: main
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
integrations/sonarqube/webhook_processors/analysis_webhook_processor.py
Outdated
Show resolved
Hide resolved
🚨 BugBot couldn't runBugBot is experiencing high demand right now. Try again in a few minutes by commenting "bugbot run" (requestId: serverGenReqId_f4feee94-6350-4232-aa1e-3429d3c7d068). |
…-handling-of-live-events-in-sonarqube
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.
Bug: Webhook Processing Errors in SonarQube
The SonarQube webhook processor introduces two issues:
- Non-On-Premise (SonarCloud): The analysis webhook now processes all project analyses using
get_analysis_by_project
instead of the specific analysis that triggered the event viaget_analysis_for_task
. This fundamentally changes webhook behavior, leading to excessive data fetching, performance issues, and potentially irrelevant data. - On-Premise: The
sonar_client
is initialized without required metrics. This causes theget_measures_for_all_pull_requests
method to fail with aValueError
due to an emptyself.metrics
property, preventing on-premise webhook processing.
integrations/sonarqube/webhook_processors/analysis_webhook_processor.py#L24-L38
ocean/integrations/sonarqube/webhook_processors/analysis_webhook_processor.py
Lines 24 to 38 in 52c73e2
sonar_client = init_sonar_client() | |
analysis_data = [] | |
project = await sonar_client.get_single_component(payload["project"]) | |
if ocean.integration_config["sonar_is_on_premise"]: | |
analysis_data = await sonar_client.get_measures_for_all_pull_requests( | |
project["key"] | |
) | |
else: | |
async for updated_analysis in sonar_client.get_analysis_by_project(project): | |
if updated_analysis: | |
analysis_data.extend(updated_analysis) |
Bug: SonarQube Client Missing Metrics Initialization
The analysis_webhook_processor
no longer initializes the sonar_client
with metrics. Previously, metrics were extracted from the webhook payload and passed to init_sonar_client
. This change is inconsistent with other webhook processors (e.g., project, issue) that configure metrics, causing the SonarQube client to operate without required metrics and potentially leading to missing or incorrect analysis data.
integrations/sonarqube/webhook_processors/analysis_webhook_processor.py#L24-L25
ocean/integrations/sonarqube/webhook_processors/analysis_webhook_processor.py
Lines 24 to 25 in 52c73e2
sonar_client = init_sonar_client() |
Was this report helpful? Give feedback by reacting with 👍 or 👎
…-handling-of-live-events-in-sonarqube
…-handling-of-live-events-in-sonarqube
…-handling-of-live-events-in-sonarqube
User description
Description
What -
Added selectors to webhook processors to match selectors on resync
reorder webhook processors to temporarily fix issues with
project blueprint
failing when issues blueprintWhy -
Differences between webhooks data and resync data due to selector changes
How -
Add the selector filters to all the webhook processor
Type of change
Please leave one option from the following and delete the rest:
All tests should be run against the port production environment(using a testing org).
Core testing checklist
Integration testing checklist
examples
folder in the integration directory.Preflight checklist
Screenshots
Include screenshots from your environment showing how the resources of the integration will look.
API Documentation
Provide links to the API documentation used for this integration.
PR Type
Bug fix
Description
• Fix webhook processors to use selectors matching resync behavior
• Reorder webhook processors to prevent project blueprint failures
• Switch analysis from task-based to project-based approach
• Add fallback data handling for webhook events
Changes walkthrough 📝
2 files
Minor formatting and comment fixes
Remove trailing comma from metrics list
4 files
Reorder webhook processor registration
Switch from task-based to project-based analysis
Add selector support and fallback handling
Add selector support and fallback handling
1 files
Add selector metrics extraction utility function
1 files
Add debug logging for payload validation