incubator-devlake icon indicating copy to clipboard operation
incubator-devlake copied to clipboard

[Bug][Sonarqube] Can not load data scope

Open ces-truongvu opened this issue 1 year ago • 17 comments

Search before asking

  • [X] I had searched in the issues and found no similar issues.

What happened

Add Sonarqube connection successfully but its projects not loaded when adding Data scope.

What do you expect to happen

Should show Sonarqube projects.

How to reproduce

  1. Added & test connection succesfully
  2. Add data scope, it shows nothing in the popup window

image

Anything else

I found out that the key of the organization is required. Seems you are using deprecated API, check it out here.

Version

v0.21.0-beta6

Are you willing to submit PR?

  • [ ] Yes I am willing to submit a PR!

Code of Conduct

ces-truongvu avatar Mar 04 '24 04:03 ces-truongvu

@ces-truongvu This seems to be a problem with filling in the connection, and the test connection does have a bug, which causes the user to test successfully even if he fills in the wrong information. image

abeizn avatar Mar 05 '24 04:03 abeizn

@ces-truongvu It will take effect in v0.21.0-beta7 version, expected to be released this week.

abeizn avatar Mar 05 '24 09:03 abeizn

@abeizn Thank you.

ces-truongvu avatar Mar 06 '24 02:03 ces-truongvu

Hi @abeizn,

I've updated to the latest version (v0.21.0.beta7), I believe this issue still not be fixed.

Steps to produce

Test connection works

Screenshot from 2024-03-08 14-15-43

But data scope does not show my projects.

image

What I found out

So, I've started development environment and modified the following file backend/plugins/sonarqube/api/remote_api.go by adding the required query string (organization) as it was written here, then it shows my projects.

image

I wish I can create the PR but I am not familiar with Golang. I hope that helpful. Thanks.

ces-truongvu avatar Mar 08 '24 07:03 ces-truongvu

@ces-truongvu Are you using the sonarcloud version? We do not support sonarcloud yet, the corresponding issue is: https://github.com/apache/incubator-devlake/issues/4838.

The supported versions are shown in this document: https://devlake.apache.org/docs/Plugins/sonarqube

abeizn avatar Mar 11 '24 14:03 abeizn

@ces-truongvu Are you using the sonarcloud version? We do not support sonarcloud yet, the corresponding issue is: #4838.

The supported versions are shown in this document: https://devlake.apache.org/docs/Plugins/sonarqube

@abeizn Yes, I'm using Sonar cloud. Got it, thanks for your support.

ces-truongvu avatar Mar 12 '24 02:03 ces-truongvu

@ces-truongvu - We are using SonarQube Server - Enterprise EditionVersion 9.9.2 (build 77730). Connection is shown as successful. I still dont see projects. They are not loaded when adding Data scope. Can you please assist.

mrpaapi avatar Mar 12 '24 16:03 mrpaapi

@ces-truongvu - We are using SonarQube Server - Enterprise EditionVersion 9.9.2 (build 77730). Connection is shown as successful. I still dont see projects. They are not loaded when adding Data scope. Can you please assist.

@mrpaapi Devlake only supports SonarQube v8.x, v9.x. Find out more here.

ces-truongvu avatar Mar 28 '24 08:03 ces-truongvu

I'm not sure this issue is resolved?

I'm using 1.0.0-beta9 and still seeing the same behaviour.

When going to "Manage Connection" and click test, the UI says succeeded, but if you look at the logs, it actually failed.

When viewing the scopes, and you click test connection, this time it correct says disconnected / failed, and then not return anything.

The (redacted html) response from the search api on sonarqube is :

	<body>
	    <div id="content">
	        <div class="global-loading">
	            <i class="spinner global-loading-spinner"></i> 
	            <span aria-live="polite" class="global-loading-text">Loading...</span>
	        </div>
	    </div>
	    <script>
	        window.baseUrl = '';
	        window.serverStatus = 'UP';
	        window.instance = 'SonarQube';
	        window.official = true;
	    </script>
	    <script type="module" src="/js/outDBSRE6XU.js"></script>
	</body>

The response should be json, not html which is why this fails.

marais-vzc avatar May 28 '24 11:05 marais-vzc

Hmm, fault exists between chair and keyboard. Well, kindoff...

I realised that I entered the url wrong. I omitted the /api/ path in the url. Now I have it consistently returning with the correct json response from the API, but I still don't get any scopes back 🤔

marais-vzc avatar May 28 '24 16:05 marais-vzc

Hmm, fault exists between chair and keyboard. Well, kindoff...

I realised that I entered the url wrong. I omitted the /api/ path in the url. Now I have it consistently returning with the correct json response from the API, but I still don't get any scopes back 🤔

@marais-vzc What's the sonarqube's version that you are using?

d4x1 avatar Jun 05 '24 11:06 d4x1

Latest LTS - SonarQube DC 9.9.5

mieliespoor avatar Jun 05 '24 20:06 mieliespoor

SonarQube >9.2 and SonarCloud are not supported at this point. Collecting vote.

klesh avatar Jun 06 '24 02:06 klesh

When can we expect to get DevLake support for SonarQube Enterprise Edition 10.5.1?

sr2530 avatar Jun 06 '24 23:06 sr2530

@sr2530 No one is working on it at this point, we are open for anyone who would like to contribute.

klesh avatar Jun 07 '24 09:06 klesh

This issue has been automatically marked as stale because it has been inactive for 60 days. It will be closed in next 7 days if no further activity occurs.

github-actions[bot] avatar Aug 07 '24 00:08 github-actions[bot]

not stale

mieliespoor avatar Aug 07 '24 07:08 mieliespoor

@sr2530 No one is working on it at this point, we are open for anyone who would like to contribute.

Someone had submitted a PR, it just needs to be approved. https://github.com/apache/incubator-devlake/pull/7849

jphelpsqred avatar Oct 07 '24 15:10 jphelpsqred

FYI. I am working on the Sonarcloud support now.

klesh avatar Oct 08 '24 02:10 klesh

Hey everyone!

I'm experiencing a similar issue with the SonarCloud integration. I've successfully added the SonarCloud connection, but I'm encountering errors when trying to retrieve data from some specific repositories.

My setup:

  • Using SonarCloud (not self-hosted SonarQube)
  • Multiple repositories configured in SonarCloud
  • DevLake version: v0.21.0-beta6 (same as reported in the issue)

Symptoms:

  • The connection test passes successfully
  • When collecting data, I get consistent 404 errors for specific repositories

Here's an excerpt of the error log I'm seeing:

subtask CollectAdditionalFilemetrics ended unexpectedly Wraps: (2) Error waiting for async Collector execution Wraps: (3) | combined messages: | { | Retry exceeded 3 times calling measures/component_tree. The last error was: Http DoAsync error calling [method:GET path:measures/component_tree query:map[ component:[myorg_web-api] metricKeys:[duplicated_lines_ density,duplicated_blocks,duplicated_lines, duplicated_files, complexity, cognitive_complexity, effort_to_reach_maintainability_rating_a, lines] p:[10] ps :[100] qualifiers:[FIL]]]. Response: {"errors":[{"msg":"Project doesn\u0027t exist"}]} (404)

The key issue appears to be that DevLake is trying to access a project with component ID myorg_web-api (I've anonymized the ID), but SonarCloud is responding with "Project doesn't exist" (404).

This project exists in my SonarCloud organization, and I can access it through the SonarCloud UI. However, DevLake consistently fails with the same error when trying to collect metrics for this repository. I've tried to call the measures/component_tree endpoint manually and I've noticed this is only happening in two repositories so far on my organization.

Has anyone else encountered similar problems with certain repositories in SonarCloud? Any suggestions for troubleshooting would be greatly appreciated.

Thanks for your help!

rgcouto avatar Jun 17 '25 15:06 rgcouto

Hey everyone!

I'm experiencing a similar issue with the SonarCloud integration. I've successfully added the SonarCloud connection, but I'm encountering errors when trying to retrieve data from some specific repositories.

My setup:

  • Using SonarCloud (not self-hosted SonarQube)
  • Multiple repositories configured in SonarCloud
  • DevLake version: v0.21.0-beta6 (same as reported in the issue)

Symptoms:

  • The connection test passes successfully
  • When collecting data, I get consistent 404 errors for specific repositories

Here's an excerpt of the error log I'm seeing:

subtask CollectAdditionalFilemetrics ended unexpectedly Wraps: (2) Error waiting for async Collector execution Wraps: (3) | combined messages: | { | Retry exceeded 3 times calling measures/component_tree. The last error was: Http DoAsync error calling [method:GET path:measures/component_tree query:map[ component:[myorg_web-api] metricKeys:[duplicated_lines_ density,duplicated_blocks,duplicated_lines, duplicated_files, complexity, cognitive_complexity, effort_to_reach_maintainability_rating_a, lines] p:[10] ps :[100] qualifiers:[FIL]]]. Response: {"errors":[{"msg":"Project doesn\u0027t exist"}]} (404)

The key issue appears to be that DevLake is trying to access a project with component ID myorg_web-api (I've anonymized the ID), but SonarCloud is responding with "Project doesn't exist" (404).

This project exists in my SonarCloud organization, and I can access it through the SonarCloud UI. However, DevLake consistently fails with the same error when trying to collect metrics for this repository. I've tried to call the measures/component_tree endpoint manually and I've noticed this is only happening in two repositories so far on my organization.

Has anyone else encountered similar problems with certain repositories in SonarCloud? Any suggestions for troubleshooting would be greatly appreciated.

Thanks for your help!

I've eventually found out that the problem was related to the lack of "Browser Project" permissions on the Sonar user rather than a problem with the DevLake integration.

Nothing to see here, then 😄

rgcouto avatar Jun 18 '25 11:06 rgcouto

@rgcouto, great find! Would you like to add it to the document? If so, here is the website repo https://github.com/apache/incubator-devlake-website

klesh avatar Jun 19 '25 07:06 klesh