PR Decoration with Bitbucket exception

Hi everyone,

I have configured SonarQube server with my Bitbucket instance.
From time to time, not all PR decorations are published to my Bitbucket.

This is what I found in ce.log:

IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 4 column 1 path $

2020.09.08 10:20:09 WARN  ce[AXRtOtjlpb-vRug67ro4][c.s.C.D.A.F] Pull request decoration did not happen. Failed to access Bitbucket Server, the repository or the pull request
    com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 4 column 1 path $
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226)
	at com.google.gson.Gson.fromJson(Gson.java:932)
	at com.google.gson.Gson.fromJson(Gson.java:870)
	at com.sonarsource.C.D.A.A.C.C(Unknown Source)
	at com.sonarsource.C.D.A.A.C.A(Unknown Source)
	at com.sonarsource.C.D.A.A.C.A(Unknown Source)
	at com.sonarsource.C.D.A.A.C.A(Unknown Source)
	at com.sonarsource.C.D.A.F.A(Unknown Source)
	at com.sonarsource.C.D.A.F.A(Unknown Source)
	at com.sonarsource.C.D.A.B.A(Unknown Source)
	at com.sonarsource.C.D.c.A(Unknown Source)
	at java.base/java.util.Optional.ifPresent(Optional.java:183)
	at com.sonarsource.C.D.c.B(Unknown Source)
	at com.sonarsource.C.D.c.A(Unknown Source)
	at org.sonar.ce.async.SynchronousAsyncExecution.addToQueue(SynchronousAsyncExecution.java:27)
	at com.sonarsource.C.D.c.A(Unknown Source)
	at java.base/java.util.Optional.ifPresent(Optional.java:183)
	at com.sonarsource.C.D.c.finished(Unknown Source)
	at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.executeTask(PostProjectAnalysisTasksExecutor.java:118)
	at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.finished(PostProjectAnalysisTasksExecutor.java:109)
	at org.sonar.ce.task.step.ComputationStepExecutor.executeListener(ComputationStepExecutor.java:91)
	at org.sonar.ce.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:63)
	at org.sonar.ce.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(ReportTaskProcessor.java:81)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.executeTask(CeWorkerImpl.java:235)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.run(CeWorkerImpl.java:217)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(CeWorkerImpl.java:162)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$TrackRunningState.get(CeWorkerImpl.java:137)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:89)
	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.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 4 column 1 path $
	at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:386)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:215)
	... 37 common frames omitted

Can anyone help me with this?

Thanks

Hi, this issue most likely appear is you misspelled your BitBucket Server API endpoint: the result returned is not json but plaintext.

Hi @pierreguillot thanks for replying,

The only place where I set Bitbucket url in SonarQube is in ALM Integrations part of the administration. I’m not sure if you think about that (Bitbucket Server url field) when you talk about Bitbucket Server API endpoint. If that is the case, then none of the PR decorations should work right? In my case, 90% of PR decorations are working.

Thanks

Ah indeed, I missed that, my bad. Yeah so something is sometimes wrong in your case, but unfortunately, we lack debug information on the integration we did. I created a ticket on SonarQube side to print more information in debug mode in failing cases such as this one.

I’m sorry to not have a workaround nor a solution yet.

Hi @pierreguillot,

Thank you for that. What is the bast way to be informed of the status change for that ticket? I cannot watch/vote for the ticket because I do not have a account. Could you update this ticket here once the other one is done?

Thanks again

If it’s me who tackles it, yes I will. Can’t promise if it’s another developer :slight_smile: but I referenced this thread in the ticket.

Aaand you should be able to sign up for an account.

 
:slight_smile:
Ann

Yes I just created my account. Thanks!