Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Gitlab] Error while decorating the request #445

Closed
sfaqer opened this issue Sep 16, 2021 · 3 comments
Closed

[Gitlab] Error while decorating the request #445

sfaqer opened this issue Sep 16, 2021 · 3 comments
Labels
awaiting release Merged but not currently in release version bug Something isn't working

Comments

@sfaqer
Copy link
Contributor

sfaqer commented Sep 16, 2021

Describe the bug
Found error in CE logs, MR not decorated

Expected behavior
MR successful decorated

Software Versions

  • SonarQube Version: 9.0.1 (build 46107)
  • Plugin Version: 1.9.0
  • Docker image: mc1arke/sonarqube-with-community-branch-plugin:9.0-community

Additional context

sonarqube_1  | 2021.09.15 08:05:11 INFO  ce[AXvofOU_UQuhcpSys54E][c.g.m.s.p.c.p.PullRequestPostAnalysisTask] using pull request decorator com.github.mc1arke.sonarqube.plugin.ce.pullrequest.gitlab.GitlabMergeRequestDecorator
sonarqube_1  | 2021.09.15 08:05:12 ERROR ce[AXvofOU_UQuhcpSys54E][c.g.m.s.p.a.g.GitlabRestClient] Gitlab response status did not match expected value. Expected: 201\nHttpResponseProxy{HTTP/1.1 400 Bad Request [Server: nginx, Date: Wed, 15 Sep 2021 08:05:12 GMT, Content-Type: application/json, Content-Length: 107, Connection: keep-alive, Cache-Control: no-cache, Vary: Origin, X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN, X-Request-Id: 01FFM7T0RH6WGZS0KPXTMBQ44E, X-Runtime: 0.074482] ResponseEntityProxy{[Content-Type: application/json,Content-Length: 107,Chunked: false]}}\n{"message":"400 Bad request - Note {:line_code=\u003e[\"can't be blank\", \"must be a valid line code\"]}"}
sonarqube_1  | 2021.09.15 08:05:12 ERROR ce[AXvofOU_UQuhcpSys54E][o.s.c.t.p.a.p.PostProjectAnalysisTasksExecutor] Execution of task class com.github.mc1arke.sonarqube.plugin.ce.pullrequest.PullRequestPostAnalysisTask failed
sonarqube_1  | java.lang.IllegalStateException: An unexpected response code was returned from the Gitlab API - Expected: 201, Got: 400
sonarqube_1  |  at com.github.mc1arke.sonarqube.plugin.almclient.gitlab.GitlabRestClient.validateResponse(GitlabRestClient.java:230)
sonarqube_1  |  at com.github.mc1arke.sonarqube.plugin.almclient.gitlab.GitlabRestClient.lambda$addMergeRequestDiscussion$0(GitlabRestClient.java:115)
sonarqube_1  |  at com.github.mc1arke.sonarqube.plugin.almclient.gitlab.GitlabRestClient.entity(GitlabRestClient.java:175)
sonarqube_1  |  at com.github.mc1arke.sonarqube.plugin.almclient.gitlab.GitlabRestClient.addMergeRequestDiscussion(GitlabRestClient.java:115)
sonarqube_1  |  at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.gitlab.GitlabMergeRequestDecorator.submitCommitNoteForIssue(GitlabMergeRequestDecorator.java:155)
sonarqube_1  |  at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.gitlab.GitlabMergeRequestDecorator.submitCommitNoteForIssue(GitlabMergeRequestDecorator.java:52)
sonarqube_1  |  at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.DiscussionAwarePullRequestDecorator.lambda$decorateQualityGateStatus$5(DiscussionAwarePullRequestDecorator.java:99)
sonarqube_1  |  at java.base/java.util.ArrayList.forEach(Unknown Source)
sonarqube_1  |  at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.DiscussionAwarePullRequestDecorator.decorateQualityGateStatus(DiscussionAwarePullRequestDecorator.java:99)
sonarqube_1  |  at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.PullRequestPostAnalysisTask.finished(PullRequestPostAnalysisTask.java:160)
sonarqube_1  |  at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.executeTask(PostProjectAnalysisTasksExecutor.java:110)
sonarqube_1  |  at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.finished(PostProjectAnalysisTasksExecutor.java:101)
sonarqube_1  |  at org.sonar.ce.task.step.ComputationStepExecutor.executeListener(ComputationStepExecutor.java:91)
sonarqube_1  |  at org.sonar.ce.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:63)
sonarqube_1  |  at org.sonar.ce.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(ReportTaskProcessor.java:81)
sonarqube_1  |  at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.executeTask(CeWorkerImpl.java:212)
sonarqube_1  |  at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.run(CeWorkerImpl.java:194)
sonarqube_1  |  at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(CeWorkerImpl.java:160)
sonarqube_1  |  at org.sonar.ce.taskprocessor.CeWorkerImpl$TrackRunningState.get(CeWorkerImpl.java:135)
sonarqube_1  |  at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:87)
sonarqube_1  |  at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:53)
sonarqube_1  |  at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
sonarqube_1  |  at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:69)
sonarqube_1  |  at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
sonarqube_1  |  at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
sonarqube_1  |  at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
sonarqube_1  |  at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
sonarqube_1  |  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
sonarqube_1  |  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
sonarqube_1  |  at java.base/java.lang.Thread.run(Unknown Source)
sonarqube_1  | 2021.09.15 08:05:12 INFO  ce[AXvofOU_UQuhcpSys54E][o.s.c.t.p.a.p.PostProjectAnalysisTasksExecutor] Pull Request Decoration | status=FAILED | time=306ms
@sfaqer sfaqer added the bug Something isn't working label Sep 16, 2021
@mc1arke
Copy link
Owner

mc1arke commented Sep 16, 2021

I'd need some more details to help replicate this:

  1. Does this consistently fail for this MR if you were to re-run it?
  2. Do you have this fail for other MRs?
  3. Are you doing anything like amending commits whilst your build is running?

sfaqer added a commit to sfaqer/sonarqube-community-branch-plugin that referenced this issue Sep 16, 2021
Added encoding for entity sending to gitlab.

Currently the Gitlab decorator does not set an encoding when sending the merge request decoration details to Gitlab, which results in some characters - such as the Cyrillic alphabet - being rendered incorrectly on Gitlab, or if that character found on old \ new path position occurs error in API. Explicitly specifying UTF-8 as the encoding overcome this.
@sfaqer
Copy link
Contributor Author

sfaqer commented Sep 16, 2021

Does this consistently fail for this MR if you were to re-run it?

Yes

Do you have this fail for other MRs?

Yes

Are you doing anything like amending commits whilst your build is running?

no

btw i found error and fix it in #446 =)

mc1arke added a commit that referenced this issue Oct 9, 2021
When calling the Gitlab API with content that contains accented or cyrillic characters, the API returns an error response and fails to complete the decoration. Explicitly setting the encoding for all body content to UTF-8 on Gitlab API requests results in the content being encoded in a way for the Gitlab API handles correctly.
mc1arke added a commit that referenced this issue Oct 9, 2021
When calling the Gitlab API with content that contains accented or cyrillic characters, the API returns an error response and fails to complete the decoration. Explicitly setting the encoding for all body content to UTF-8 on Gitlab API requests results in the content being encoded in a way for the Gitlab API handles correctly.
mc1arke added a commit that referenced this issue Oct 9, 2021
When calling the Gitlab API with content that contains accented or cyrillic characters, the API returns an error response and fails to complete the decoration. Explicitly setting the encoding for all body content to UTF-8 on Gitlab API requests results in the content being encoded in a way for the Gitlab API handles correctly.
@mc1arke mc1arke added awaiting release Merged but not currently in release version backport candidate This feature or fix should be included in another release branch labels Oct 9, 2021
@mc1arke
Copy link
Owner

mc1arke commented Dec 18, 2021

Released in 1.10.0 of the plugin

@mc1arke mc1arke closed this as completed Dec 18, 2021
mc1arke added a commit that referenced this issue Jun 19, 2022
When calling the Gitlab API with content that contains accented or cyrillic characters, the API returns an error response and fails to complete the decoration. Explicitly setting the encoding for all body content to UTF-8 on Gitlab API requests results in the content being encoded in a way for the Gitlab API handles correctly.
mc1arke added a commit that referenced this issue Jun 19, 2022
When calling the Gitlab API with content that contains accented or cyrillic characters, the API returns an error response and fails to complete the decoration. Explicitly setting the encoding for all body content to UTF-8 on Gitlab API requests results in the content being encoded in a way for the Gitlab API handles correctly.
@mc1arke mc1arke removed the backport candidate This feature or fix should be included in another release branch label Jun 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting release Merged but not currently in release version bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants