mc1arke / sonarqube-community-branch-plugin

A plugin that allows branch analysis and pull request decoration in the Community version of Sonarqube
GNU Lesser General Public License v3.0
2.2k stars 513 forks source link

Github API is returning 'Expected string or block string, but it was malformed' #959

Closed Tsuesun closed 2 weeks ago

Tsuesun commented 2 weeks ago

Describe the bug Github API is returning 'Expected string or block string, but it was malformed' when trying to decorate the PR. This occurred suddenly today.

To Reproduce Steps to reproduce the behavior: Unknown

Expected behavior Github API returns a 200 and pull request decoration completes

Software Versions

Additional context Add any other context about the problem here.

2024.09.03 00:57:04 ERROR ce[AZG1YpEQP4vylyjzcyxf][o.s.c.t.p.a.p.PostProjectAnalysisTasksExecutor] Execution of task class com.github.mc1arke.sonarqube.plugin.ce.pullrequest.PullRequestPostAnalysisTask failed
java.lang.IllegalStateException: Could not decorate Pull Request on Github
    at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.github.GithubPullRequestDecorator.decorateQualityGateStatus(GithubPullRequestDecorator.java:95)
    at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.PullRequestPostAnalysisTask.finished(PullRequestPostAnalysisTask.java:146)
    at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.executeTask(PostProjectAnalysisTasksExecutor.java:102)
    at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.finished(PostProjectAnalysisTasksExecutor.java:93)
    at org.sonar.ce.task.step.ComputationStepExecutor.executeListener(ComputationStepExecutor.java:89)
    at org.sonar.ce.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:61)
    at org.sonar.ce.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(ReportTaskProcessor.java:75)
    at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.executeTask(CeWorkerImpl.java:212)
    at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.run(CeWorkerImpl.java:194)
    at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(CeWorkerImpl.java:160)
    at org.sonar.ce.taskprocessor.CeWorkerImpl$TrackRunningState.get(CeWorkerImpl.java:135)
    at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:87)
    at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:53)
    at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
    at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)
    at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: An error was returned in the response from the Github API:
- Error{message='Expected string or block string, but it was malformed', locations=[Location{line='1', column='70'}]}
    at com.github.mc1arke.sonarqube.plugin.almclient.github.v4.GraphqlGithubClient.executeRequest(GraphqlGithubClient.java:246)
    at com.github.mc1arke.sonarqube.plugin.almclient.github.v4.GraphqlGithubClient.createCheckRun(GraphqlGithubClient.java:111)
    at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.github.GithubPullRequestDecorator.decorateQualityGateStatus(GithubPullRequestDecorator.java:87)
    ... 21 common frames omitted
fegbers commented 2 weeks ago

We have had the same problem since yesterday (=> ~ 3PM UTC 2nd September).

mc1arke commented 2 weeks ago

Is this Github cloud or Github enterprise (self hosted)?

Tsuesun commented 2 weeks ago

Github cloud in my case

fegbers commented 2 weeks ago

GitHub cloud as well

pedrocarrico commented 2 weeks ago

I'm also having this exact same issue since yesterday and same message on the logs as @Tsuesun

DEBUG logs also show the following:

2024.09.03 06:58:26 DEBUG ce[a3272367-2d70-4e58-a5bd-7e9b1efc433f][c.g.m.s.p.a.g.v.GraphqlGithubClient] Using request: mutation { createCheckRun (input:{conclusion:SUCCESS,output:{summary:"![Passed](https://raw.githubusercontent.com/mc1arke/sonarqube-community-branch-plugin/master/src/main/resources/static/checks/QualityGateBadge/passed.png)\n\n# Analysis Details\n## 0 Issues\n- [![Bug](https://raw.githubusercontent.com/mc1arke/sonarqube-community-branch-plugin/master/src/main/resources/static/common/bug.png)](https://redacted.example.org/project/issues?pullRequest=2676&resolved=false&types=BUG&inNewCodePeriod=true&id=redacted_example_21dfd0aa-349e-4cf0-ae55-811a8f7b56b7) 0 Bugs\n- [![Vulnerability](https://raw.githubusercontent.com/mc1arke/sonarqube-community-branch-plugin/master/src/main/resources/static/common/vulnerability.png)](https://redacted.example.org/project/issues?pullRequest=2676&resolved=false&types=VULNERABILITY&inNewCodePeriod=true&id=redacted_example_21dfd0aa-349e-4cf0-ae55-811a8f7b56b7) 0 Vulnerabilities\n- [![Code Smell](https://raw.githubusercontent.com/mc1arke/sonarqube-community-branch-plugin/master/src/main/resources/static/common/code_smell.png)](https://redacted.example.org/project/issues?pullRequest=2676&resolved=false&types=CODE_SMELL&inNewCodePeriod=true&id=redacted_example_21dfd0aa-349e-4cf0-ae55-811a8f7b56b7) 0 Code Smells\n\n## Coverage and Duplications\n- [![Coverage](https://raw.githubusercontent.com/mc1arke/sonarqube-community-branch-plugin/master/src/main/resources/static/checks/CoverageChart/90.png)](https://redacted.example.org/component_measures?id=redacted_example_21dfd0aa-349e-4cf0-ae55-811a8f7b56b7&metric=new_coverage&pullRequest=2676&view=list) 93.30% Coverage (97.40% Estimated after merge)\n- [![Duplications](https://raw.githubusercontent.com/mc1arke/sonarqube-community-branch-plugin/master/src/main/resources/static/checks/Duplications/3.png)](https://redacted.example.org/component_measures?id=redacted_example_21dfd0aa-349e-4cf0-ae55-811a8f7b56b7&metric=new_duplicated_lines_density&pullRequest=2676&view=list) 0.00% Duplicated Code (0.00% Estimated after merge)\n\n**Project ID:** redacted_example_21dfd0aa-349e-4cf0-ae55-811a8f7b56b7\n\n[View in SonarQube](https://redacted.example.org/dashboard?id=redacted_example_21dfd0aa-349e-4cf0-ae55-811a8f7b56b7&pullRequest=2676)\n\n",annotations:[],title:"Quality Gate success"},completedAt:"2024-09-03T06:58:25Z",detailsUrl:"https://redacted.example.org/dashboard?id=redacted_example_21dfd0aa-349e-4cf0-ae55-811a8f7b56b7&pullRequest=2676",repositoryId:"MDEwOlJlcG9zaXRvcnkyNzI4MDIzMDY=",name:"example Sonarqube Results",startedAt:"2024-09-03T06:57:45Z",externalId:"8daedc9c-d934-48b0-b203-1e3f519295cd",headSha:"dfa29e4b525d4bc97da5fa683775ce4b660430b9",status:COMPLETED}) { clientMutationId checkRun { id } } } 
2024.09.03 06:58:26 DEBUG ce[a3272367-2d70-4e58-a5bd-7e9b1efc433f][c.g.m.s.p.a.g.v.GraphqlGithubClient] Received response: GraphQLResponseEntity{errors=[Error{message='Expected string or block string, but it was malformed', locations=[Location{line='1', column='70'}]}], headers=null, response=null}
kienw commented 2 weeks ago

Same issue here.

vernigora2 commented 2 weeks ago

We've had the same issue since yesterday

SonarQube Community Edition: v9.9 Plugin: 1.14 Github cloud

ashishvaishno commented 2 weeks ago

We also seen issue since yesterday SonarQube Community Edition: 10.2.1 Plugin version : 1.17.1

kasparsginters commented 2 weeks ago

Same issue. On-prem SonarQube Community Edition: 10.5.1 Plugin version : 1.19.1 GitHub: Cloud

tico24 commented 2 weeks ago

It's fairly obvious by now that this is a widespread issue. Please strongly consider just adding your thumb to the issue rather than sending these messages to everyone watching the issue.

stefan-toubia commented 2 weeks ago

We found that we had to use block strings """ for multiline text

mc1arke commented 2 weeks ago

I've proposed a fix in #961 which works for some local integration tests. It would be useful if anyone who is encountering this issue could try using the snapshot attached to the MRs pipeline to see if the fix resolves their issue. Once I have some confirmation that this works then I'll aim to get a release of the plugin out and the fix back-ported to the LTS-compatible version of the plugin.

kienw commented 2 weeks ago

I've proposed a fix in #961 which works for some local integration tests. It would be useful if anyone who is encountering this issue could try using the snapshot attached to the MRs pipeline to see if the fix resolves their issue. Once I have some confirmation that this works then I'll aim to get a release of the plugin out and the fix back-ported to the LTS-compatible version of the plugin.

@mc1arke I have tried out the snapshot. I got the snapshot from build / snapshot (17) (pull_request):

Artifact download URL: https://github.com/mc1arke/sonarqube-community-branch-plugin/actions/runs/10690893309/artifacts/1888225789

I upgraded my SonarQube version from 10.5 to 10.6, then install this snapshot plugin. It works! 🎉 Thanks! ❤️

Note: At first, I upgraded the plugin from 1.19.0 to the snapshot version on my SonarQube version 10.5, and I encountered the issue where the ElasticSearch keeps failing, and I had to restore the SonarQube VM from the backup. I wonder if it is because the plugin version is not compatible with SonarQube version 10.5, any idea?

kasparsginters commented 2 weeks ago

Did the same as @kienw Using docker to run SonarQube and PostgreSQL.

Bumped SonarQube 10.5-community to 10.6-community before applying sonarqube-community-branch-plugin-1.22.0-SNAPSHOT.jar

PR decorations working.

Thank you!

GreyTeardrop commented 2 weeks ago

I can also confirm that https://github.com/mc1arke/sonarqube-community-branch-plugin/pull/961 fixes this issue for us on GitHub cloud. Thank you!

Tsuesun commented 2 weeks ago

FYI, I got this response from Github support

<snip>
Numerous customers have reached out in the last 24 hours highlighting similar behaviour, so we've gone ahead and raised this with our engineering team for further analysis. Hopefully, they'll be able to shed some light on this in the coming days and we'll update you as soon as news becomes available. Marking this case as On-Hold for now as it's sitting with another team to address.
mc1arke commented 2 weeks ago

Released in 1.22.0

smukarramhs commented 2 weeks ago

@mc1arke can this also be released in the LTS supported version which is 1.14.0 please?

NamanNacedo commented 1 week ago

if I update sonarqube community edition it will solve this issue? or if I just update to the LTA it will work?

visu-suganya commented 1 week ago

@mc1arke Now the issue got fixed automatically in 9.9LTA and 10.2 versions without updating the plugin. I wonder what is the reason behind this?

azun-c commented 1 week ago

Is there something changed on Github side?

https://github.com/mc1arke/sonarqube-community-branch-plugin/issues/959#issuecomment-2330406190

fegbers commented 1 week ago

We have not adjusted anything either. GitHub has apparently made adjustments