SonarQube PR decoration failing intermittently with "Visit failed for Component"

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    I am using the following version - Developer Edition Version 8.2 (build 32929)
  • what are you trying to achieve
    When we create a PR in bitbucket, the PR decoration feature is failing intermittently with “Visit failed for Component” for some PR’s
  • what have you tried so far to achieve this
    Here are the Sonar Qube logs. I have created two pull request in the same project. PR-63 is failing and PR-64 is passing.
    PR-63 is failing with this exception:
    {"task":{"id":"AXcnMJlU5pae-U62aHpk","type":"REPORT","componentId":"AXcl5Bw65pae-U62aHi3","componentKey":"proverb","componentName":"proverb","componentQualifier":"TRK","status":"FAILED","submittedAt":"2021-01-21T15:03:52-0800","submitterLogin":"service-jenkins","startedAt":"2021-01-21T15:03:52-0800","executedAt":"2021-01-21T15:03:53-0800","executionTimeMs":309,"logs":false,"errorMessage":"Component name can't be empty (Visit failed for Component {key=proverb:proverb:PULL_REQUEST:63,type=DIRECTORY} located proverb:PULL_REQUEST:63(type=PROJECT))","hasScannerContext":true,"organization":"default-organization","pullRequest":"63","warningCount":0,"warnings":[]}}

PR-64 is passing:
{"task":{"id":"AXcnEEsQ5pae-U62aHpK","type":"REPORT","componentId":"AXcnCV5n5pae-U62aHpD","componentKey":"proverb","componentName":"proverb","componentQualifier":"TRK","analysisId":"AXcnEFBSQKdb2oojDAoT","status":"SUCCESS","submittedAt":"2021-01-21T14:28:35-0800","submitterLogin":"service-jenkins","startedAt":"2021-01-21T14:28:36-0800","executedAt":"2021-01-21T14:28:37-0800","executionTimeMs":715,"logs":false,"hasScannerContext":true,"organization":"default-organization","pullRequest":"64","warningCount":0,"warnings":[]}}

I am attaching two log files with the Sonar Qube logs for the two PR’s => PR-63.txt and PR-64.txt. I go those logs with verbose=True
PR-64.txt (61.8 KB) PR-63.txt (62.1 KB)

Here is complete stack trace for failing PR-63. This is using the following WebAPI - https://sonarqube.corp.xperi.com/api/ce/task?id=AXcmMNqK5pae-U62aHo6&additionalFields=stacktrace&additionalFields=scannerContext&additionalFields=warnings

{"task":{"id":"AXcmMNqK5pae-U62aHo6","type":"REPORT","componentId":"AXcl5Bw65pae-U62aHi3","componentKey":"proverb","componentName":"proverb","componentQualifier":"TRK","status":"FAILED","submittedAt":"2021-01-21T10:24:31-0800","submitterLogin":"service-jenkins","startedAt":"2021-01-21T10:24:32-0800","executedAt":"2021-01-21T10:24:32-0800","executionTimeMs":359,"logs":false,"errorMessage":"Component name can't be empty (Visit failed for Component {key=proverb:proverb:PULL_REQUEST:63,type=DIRECTORY}  located proverb:PULL_REQUEST:63(type=PROJECT))",
"errorStacktrace":"
org.sonar.ce.task.projectanalysis.component.VisitException: Visit failed for Component {key=proverb:proverb:PULL_REQUEST:63,type=DIRECTORY}  located proverb:PULL_REQUEST:63(type=PROJECT)
	at org.sonar.ce.task.projectanalysis.component.VisitException.rethrowOrWrap(VisitException.java:44)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visit(PathAwareCrawler.java:52)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visitChildren(PathAwareCrawler.java:87)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visitImpl(PathAwareCrawler.java:70)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visit(PathAwareCrawler.java:50)
	at org.sonar.ce.task.projectanalysis.step.PersistComponentsStep.execute(PersistComponentsStep.java:114)
	at org.sonar.ce.task.step.ComputationStepExecutor.executeStep(ComputationStepExecutor.java:81)
	at org.sonar.ce.task.step.ComputationStepExecutor.executeSteps(ComputationStepExecutor.java:72)
	at org.sonar.ce.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:59)
	at org.sonar.ce.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(ReportTaskProcessor.java:81)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.executeTask(CeWorkerImpl.java:209)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.run(CeWorkerImpl.java:191)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(CeWorkerImpl.java:158)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$TrackRunningState.get(CeWorkerImpl.java:133)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:85)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:53)
	at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
	at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:69)
	at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalArgumentException: Component name can't be empty
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:142)
	at org.sonar.db.component.ComponentValidator.checkComponentName(ComponentValidator.java:40)
	at org.sonar.db.component.ComponentDto.setName(ComponentDto.java:316)
	at org.sonar.ce.task.projectanalysis.step.PersistComponentsStep$PersistComponentStepsVisitor.createForDirectory(PersistComponentsStep.java:302)
	at org.sonar.ce.task.projectanalysis.step.PersistComponentsStep$PersistComponentStepsVisitor.visitDirectory(PersistComponentsStep.java:211)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visitNode(PathAwareCrawler.java:99)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visitImpl(PathAwareCrawler.java:67)
	at org.sonar.ce.task.projectanalysis.component.PathAwareCrawler.visit(PathAwareCrawler.java:50)
	... 23 more\n","hasScannerContext":true,"organization":"default-organization","pullRequest":"63","warningCount":0,"warnings":[]}}

Can you please help us out ?

Hello @arpun.nangia
the first thing to do when confronted with such problem is to check if you are on the last version and upgrade if you are not, so that you can check if your issue was not fixed already.

As you are on SonarQube 8.2, you need to upgrade to 8.6.1, which provides 136 bug fixes on top of the 8.2 (and more than 300 improvements).
I cannot tell for sure but your issue may have been fixed with SONAR-13262

For your upgrade:

  • the documentation entry point is the Upgrade the Server page
  • as advised there you need to read the upgrade notes carefully
  • it is good practice to rehearse your upgrade on a non-production environment

Let me know how it goes.
Best
Sylvain