Branch analysis fails for some branches, succeeds for others, using Azure DevOps

Hi,

We recently started using SonarQube to analyze our project built with Azure DevOps and using the branch feature.

  • versions used
    Developer Edition (7.9.0.26994)
    Azure DevOps tasks are version 4.* which turns out to be 4.6.3.

  • error observed
    When building the master branch (actually the default branch configured in DevOps) or some specific branches, the project is analyzed and results show up (also as a branch if that is the case).
    However, for some other branches, this is not the case and the results are not shown.
    In that case, the error (from DevOps) is:

[SQ] Task failed with status FAILED, Error message: Compute Engine task main component key is null. Project with UUID AWvBds-6mJnVjF3DJ_EA must have been deleted since report was uploaded. Can not proceed.

Looking at the log files on the SonarQube server, shows the following:
Branch that fails, access.log:

[16/Jul/2019:08:17:07 +0000] "POST /api/ce/submit?projectKey=sonar.supermodels&projectName=supermodels&characteristic=branch%3Dfeature%2FTC3State&characteristic=branchType%3DSHORT HTTP/1.1" 200 44 "-" "ScannerCli/3.3.0.1492" "AWvRS53FaUsW/ncwABjx"

Branch that fails, ce.log:

2019.07.16 08:17:09 INFO  ce[][o.s.c.t.CeWorkerImpl] Execute task | type=REPORT | branch=feature/TC3State | branchType=SHORT | id=AWv520zfRQdbPXa-C3g- | submitter=admin
2019.07.16 08:17:09 INFO  ce[AWv520zfRQdbPXa-C3g-][o.s.c.t.s.ComputationStepExecutor] Extract report | status=SUCCESS | time=424ms
2019.07.16 08:17:09 INFO  ce[AWv520zfRQdbPXa-C3g-][o.s.c.t.s.ComputationStepExecutor] Persist scanner context | status=SUCCESS | time=19ms
2019.07.16 08:17:09 INFO  ce[AWv520zfRQdbPXa-C3g-][o.s.c.t.s.ComputationStepExecutor] Propagate analysis warnings from scanner report | status=SUCCESS | time=0ms
2019.07.16 08:17:09 INFO  ce[AWv520zfRQdbPXa-C3g-][o.s.c.t.s.ComputationStepExecutor] Execute DB migrations for current project | status=SUCCESS | time=1ms
2019.07.16 08:17:09 INFO  ce[AWv520zfRQdbPXa-C3g-][o.s.c.t.s.ComputationStepExecutor] Generate analysis UUID | status=SUCCESS | time=1ms
2019.07.16 08:17:09 INFO  ce[AWv520zfRQdbPXa-C3g-][o.s.c.t.s.ComputationStepExecutor] Load analysis metadata | status=FAILED | time=3ms
2019.07.16 08:17:09 ERROR ce[AWv520zfRQdbPXa-C3g-][o.s.c.t.s.ComputationStepExecutor] Execution of listener failed
java.lang.IllegalStateException: Missing project key
	at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.lambda$createProject$1(PostProjectAnalysisTasksExecutor.java:154)
	(...)
	at java.base/java.lang.Thread.run(Thread.java:834)
2019.07.16 08:17:09 INFO  ce[AWv520zfRQdbPXa-C3g-][o.s.c.t.CeWorkerImpl] Executed task | type=REPORT | branch=feature/TC3State | branchType=SHORT | id=AWv520zfRQdbPXa-C3g- | submitter=admin | status=FAILED | time=624ms

Branch that succeeds, access.log:

[16/Jul/2019:09:08:11 +0000] "POST /api/ce/submit?projectKey=sonar.supermodels&projectName=supermodels&characteristic=branch%3DFeature%2FRoslyn&characteristic=branchType%3DSHORT HTTP/1.1" 200 44 "-" "ScannerCli/3.3.0.1492" "AWvRS53FaUsW/ncwABks"

Branch that succeeds, ce.log:

2019.07.16 09:08:12 INFO  ce[][o.s.c.t.CeWorkerImpl] Execute task | project=sonar.supermodels | type=REPORT | branch=Feature/Roslyn | branchType=SHORT | id=AWv6CgvqRQdbPXa-C3hC | submitter=admin
2019.07.16 09:08:13 INFO  ce[AWv6CgvqRQdbPXa-C3hC][o.s.c.t.s.ComputationStepExecutor] Extract report | status=SUCCESS | time=385ms
2019.07.16 09:08:13 INFO  ce[AWv6CgvqRQdbPXa-C3hC][o.s.c.t.s.ComputationStepExecutor] Persist scanner context | status=SUCCESS | time=12ms
2019.07.16 09:08:13 INFO  ce[AWv6CgvqRQdbPXa-C3hC][o.s.c.t.s.ComputationStepExecutor] Propagate analysis warnings from scanner report | status=SUCCESS | time=0ms
2019.07.16 09:08:13 INFO  ce[AWv6CgvqRQdbPXa-C3hC][o.s.c.t.s.ComputationStepExecutor] Execute DB migrations for current project | status=SUCCESS | time=2ms
2019.07.16 09:08:13 INFO  ce[AWv6CgvqRQdbPXa-C3hC][o.s.c.t.s.ComputationStepExecutor] Generate analysis UUID | status=SUCCESS | time=0ms
2019.07.16 09:08:13 INFO  ce[AWv6CgvqRQdbPXa-C3hC][o.s.c.t.s.ComputationStepExecutor] Load analysis metadata | status=SUCCESS | time=12ms
2019.07.16 09:08:13 INFO  ce[AWv6CgvqRQdbPXa-C3hC][o.s.c.t.s.ComputationStepExecutor] Initialize | status=SUCCESS | time=3ms
(...)
2019.07.16 09:08:36 INFO  ce[AWv6CgvqRQdbPXa-C3hC][o.s.c.t.CeWorkerImpl] Executed task | project=sonar.supermodels | type=REPORT | branch=Feature/Roslyn | branchType=SHORT | id=AWv6CgvqRQdbPXa-C3hC | submitter=admin | status=SUCCESS | time=23659ms

It can be seen the project key is missing in the compute engine log for the failing case, but why this happens is not clear since in both cases the project key is present in the API call as can be seen in access.log. There are more branches that either succeed or fail than listed here. I’ve not been able to identify what causes some to work and others not.

  • steps to reproduce
    As mentioned, we are using Azure DevOps to build, using the standard SonarQube tasks (Prepare Analysis Configuration, Run Code Analysis, Publish Quality Gate Result). So the builds that are working and the builds that are not working are executed exactly the same way, except that they are different branches. If the analysis fails, the Publish Quality Gate Result step also fails (project cannot be found).
    The problem reproduces each time for specific branches (so if a branch analysis fails to execute, it fails each time; if it succeeds, it succeeds each time).

  • potential workaround
    None found

Any help would be appreciated.

#bug:fault

Hello @svd,

This looks to be a nasty situation. As it consistently happen on some branches and not others, let’s further check the analysis before thinking of a bug.

Could you check (in Debug mode) that the build/analysis of a working branch and a not working one behaves equally? Same/similar parameters passed, same source code scope, etc. You can attach logs here (or share in DM) to let me check if needed.

What kind of code it is and which scanner are you using?

Then it also makes sense to check CE logs in Debug mode. The error is pretty clear but the debug mode can give you better hints of the issue (check here to enable them).

Let me know if it helps.

Antoine

1 Like

Hi Antoine,

I have analyzed a branch that works and one that fails with Debug level logging. I will attach the log files to the post. Besides the ones that can be downloaded through the web interface, I see the most relevant difference (I think) in the access.log directly from the server. It is basically the same difference as indicated in the original post.

The application being analyzed is a C# (WPF) application. And the scanner is one run by the Run Code Analysis task of Azure DevOps, if that is what you mean:

==============================================================================
Task : Run Code Analysis
Description : Run scanner and upload the results to the SonarQube server.
Version : 4.6.3
Author : sonarsource

==============================================================================

What I can see is that for both branches, the POST message includes the project key, but it gets dropped when the CE is called it seems. I cannot learn anything more from the logs, perhaps you could take a look at them?

The task that succeeds is the one that was started around 11:44 in the logs.
The failing one around 12:03.

Thanks for your help!

Regards,
Sander

access.log.txt (124.5 KB) sonarqube_app.log.txt (12.4 KB) sonarqube_ce.log.txt (56.4 KB) sonarqube_es.log.txt (327 Bytes) sonarqube_web.log.txt (34.6 KB)

we are also experiencing the same problem - i even deleted project in sonar cloud and recreated it from scratch but the problem persist. Is there any fix for it?

Hi,

Any update on this problem or solution.
Recently i am facing the same problem with one of my projects.

This obviously went off the radar…

@Umer_Siddiqi, on SonarQube as well or SonarCloud? In any case, please open another thread and attach all the meaningful info (debug logs, config), we need the full context for this kind of issues. Make sure you are using the latest versions of all the stack (Scanner/AzureDevops tasks, SQ and analyzers if it’s on SQ).

Thanks

Hi Antoine,

It was happening on SonarCloud. I even tried delete the project on SonarCloud side couple of times but it didn’t solve the problem.
Yesterday I updated the project key and it solved the problem.
I will open another thread, if the same problem occurs again.

Thanks!