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.22k stars 520 forks source link

Could not decorate Github merge request. Resource not accessible by integration #977

Closed hungphaminnomizetech closed 4 days ago

hungphaminnomizetech commented 1 week ago

Describe the bug I get this when I create a merge request but don't receive any analysis details. 1 month ago I tried to apply it and it is working well, but now when I create a merge request then I see an error on Sonarqube like this 2024.10.10 03:20:28 INFO ce[d6bbd618-7c39-43af-a72a-e21f04c45143][c.g.m.s.p.c.p.PullRequestPostAnalysisTask] Using pull request decorator com.github.mc1arke.sonarqube.plugin.ce.pullrequest.github.GithubPullRequestDecorator

2024.10.10 03:20:30 ERROR ce[d6bbd618-7c39-43af-a72a-e21f04c45143][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:96)
        at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.PullRequestPostAnalysisTask.finished(PullRequestPostAnalysisTask.java:139)
        at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.executeTask(PostProjectAnalysisTasksExecutor.java:101)
        at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.finished(PostProjectAnalysisTasksExecutor.java:92)
        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:76)
        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='Resource not accessible by integration', locations=[Location{line='1', column='12'}]}
        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:109)
        at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.github.GithubPullRequestDecorator.decorateQualityGateStatus(GithubPullRequestDecorator.java:88)
        ... 21 common frames omitted
   I don't change any permission and settings on the GitHub app or SonarQube. I also change to use the latest version 1.22.0 for sonarqube-community-branch-plugin.
   Please give me advices
codiasm commented 1 week ago

This is a duplicate of #969

hungphaminnomizetech commented 4 days ago

Thanks @codiasm,

I checked your Merge Request to fix the issue. However, my issue is not related to this one. My problem was Resource not accessible by integration, and while your merge request didn’t resolve it, I took the time to debug and investigate further. It turns out the GitHub App required additional permissions for contents (read and write), which I had missed.

After updating the permissions and reinstalling the GitHub App, my issue was resolved, and the analysis details for Pull/Merge Requests are now showing correctly.

Thanks again!