Skip to content
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

[Integration][SonarQube] Bug | 404 response when querying SonarQube issues #1105

Merged
merged 8 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions integrations/sonarqube/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- towncrier release notes start -->

## 0.1.105 (2024-10-29)


### Bug Fixes

- Fixed bug where issues/list API is not available for older SonarQube instance versions


## 0.1.104 (2024-10-23)


Expand Down
12 changes: 4 additions & 8 deletions integrations/sonarqube/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class Endpoints:
WEBHOOKS = "webhooks"
MEASURES = "measures/component"
BRANCHES = "project_branches/list"
ONPREM_ISSUES = "issues/list"
SAAS_ISSUES = "issues/search"
ISSUES_SEARCH = "issues/search"
ANALYSIS = "activity_feed/list"
PORTFOLIO_DETAILS = "views/show"
PORTFOLIOS = "views/list"
Expand Down Expand Up @@ -160,7 +159,7 @@ async def send_paginated_api_request(
if (
e.response.status_code == 400
and query_params.get("ps", 0) > PAGE_SIZE
and endpoint in [Endpoints.ONPREM_ISSUES, Endpoints.SAAS_ISSUES]
and endpoint == Endpoints.ISSUES_SEARCH
):
logger.error(
"The request exceeded the maximum number of issues that can be returned (10,000) from SonarQube API. Consider using apiFilters in the config mapping to narrow the scope of your search. Returning accumulated issues and skipping further results."
Expand Down Expand Up @@ -336,20 +335,17 @@ async def get_issues_by_component(
"""
component_issues = []
component_key = component.get("key")
endpoint_path = ""

if self.is_onpremise:
query_params = {"project": component_key}
endpoint_path = Endpoints.ONPREM_ISSUES
query_params = {"components": component_key}
else:
query_params = {"componentKeys": component_key}
endpoint_path = Endpoints.SAAS_ISSUES

if api_query_params:
query_params.update(api_query_params)

response = await self.send_paginated_api_request(
endpoint=endpoint_path,
endpoint=Endpoints.ISSUES_SEARCH,
data_key="issues",
query_params=query_params,
)
Expand Down
2 changes: 1 addition & 1 deletion integrations/sonarqube/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sonarqube"
version = "0.1.104"
version = "0.1.105"
description = "SonarQube projects and code quality analysis integration"
authors = ["Port Team <[email protected]>"]

Expand Down