mibexsoftware / sonar-bitbucket-plugin

SonarQube plug-in to create pull request comments for found issues in Bitbucket Cloud
Other
122 stars 72 forks source link

UniformInterfaceException HTTP 429 Bitbucket Cloud #77

Open goliveiragabriel opened 6 years ago

goliveiragabriel commented 6 years ago

Expected Behavior

Re-analyzing a pull-request on Bitbucket Cloud

Actual Behavior

I have issued an http 429 exception while re-analyzing pull requests. I found some information about rate limits on Bitbucket API Documentation. However, i guess its not a exactly scenario to reproduce it. Follow the stack trace bellow:

[Step 1/1] ERROR: Error during SonarQube Scanner execution [17:10:08] [Step 1/1] com.sun.jersey.api.client.UniformInterfaceException: PUT https://api.bitbucket.org/1.0/repositories/metaora/nix.produto/pullrequests/568/comments/57435299 returned a response status of 429 null [17:10:08] [Step 1/1] at com.sun.jersey.api.client.WebResource.voidHandle(WebResource.java:707) [17:10:08] [Step 1/1] at com.sun.jersey.api.client.WebResource.access$400(WebResource.java:74) [17:10:08] [Step 1/1] at com.sun.jersey.api.client.WebResource$Builder.put(WebResource.java:517) [17:10:08] [Step 1/1] INFO: Final Memory: 57M/427M [17:10:08] [Step 1/1] INFO: ------------------------------------------------------------------------ [17:10:08] [Step 1/1] at ch.mibex.bitbucket.sonar.client.BitbucketClient.updateReviewComment(BitbucketClient.scala:266) [17:10:08] [Step 1/1] at ch.mibex.bitbucket.sonar.review.ReviewCommentsHandler.ch$mibex$bitbucket$sonar$review$ReviewCommentsHandler$$updateComment(ReviewCommentsHandler.scala:148) [17:10:08] [Step 1/1] at ch.mibex.bitbucket.sonar.review.ReviewCommentsHandler$$anonfun$updateComments$1$$anonfun$apply$1.apply(ReviewCommentsHandler.scala:43) [17:10:08] [Step 1/1] at ch.mibex.bitbucket.sonar.review.ReviewCommentsHandler$$anonfun$updateComments$1$$anonfun$apply$1.apply(ReviewCommentsHandler.scala:37) [17:10:08] [Step 1/1] at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:99) [17:10:08] [Step 1/1] at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:99) [17:10:08] [Step 1/1] at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:230) [17:10:08] [Step 1/1] at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40) [17:10:08] [Step 1/1] at scala.collection.mutable.HashMap.foreach(HashMap.scala:99) [17:10:08] [Step 1/1] at ch.mibex.bitbucket.sonar.review.ReviewCommentsHandler$$anonfun$updateComments$1.apply(ReviewCommentsHandler.scala:37) [17:10:08] [Step 1/1] at ch.mibex.bitbucket.sonar.review.ReviewCommentsHandler$$anonfun$updateComments$1.apply(ReviewCommentsHandler.scala:36) [17:10:08] [Step 1/1] at scala.collection.immutable.Map$Map1.foreach(Map.scala:116) [17:10:08] [Step 1/1] at ch.mibex.bitbucket.sonar.review.ReviewCommentsHandler.updateComments(ReviewCommentsHandler.scala:36) [17:10:08] [Step 1/1] at ch.mibex.bitbucket.sonar.review.SonarReviewPostJob.ch$mibex$bitbucket$sonar$review$SonarReviewPostJob$$handlePullRequest(SonarReviewPostJob.scala:45) [17:10:08] [Step 1/1] at ch.mibex.bitbucket.sonar.review.SonarReviewPostJob$$anonfun$execute$1.apply(SonarReviewPostJob.scala:29) [17:10:08] [Step 1/1] at ch.mibex.bitbucket.sonar.review.SonarReviewPostJob$$anonfun$execute$1.apply(SonarReviewPostJob.scala:27) [17:10:08] [Step 1/1] at scala.collection.immutable.List.foreach(List.scala:381) [17:10:08] [Step 1/1] at ch.mibex.bitbucket.sonar.review.SonarReviewPostJob.execute(SonarReviewPostJob.scala:27) [17:10:08] [Step 1/1] at org.sonar.scanner.postjob.PostJobWrapper.executeOn(PostJobWrapper.java:58) [17:10:08] [Step 1/1] at org.sonar.scanner.phases.PostJobsExecutor.execute(PostJobsExecutor.java:66) [17:10:08] [Step 1/1] at org.sonar.scanner.phases.PostJobsExecutor.execute(PostJobsExecutor.java:55) [17:10:08] [Step 1/1] at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:94) [17:10:08] [Step 1/1] at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:180) [17:10:08] [Step 1/1] at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135) [17:10:08] [Step 1/1] at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121) [17:10:08] [Step 1/1] at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:288) [17:10:08] [Step 1/1] at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:283) [17:10:08] [Step 1/1] at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:261) [17:10:08] [Step 1/1] at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135) [17:10:08] [Step 1/1] at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121) [17:10:08] [Step 1/1] at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48) [17:10:08] [Step 1/1] at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84) [17:10:08] [Step 1/1] at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135) [17:10:08] [Step 1/1] at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121) [17:10:08] [Step 1/1] at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121) [17:10:08] [Step 1/1] at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116) [17:10:08] [Step 1/1] at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:111) [17:10:08] [Step 1/1] at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63) [17:10:08] [Step 1/1] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [17:10:08] [Step 1/1] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [17:10:08] [Step 1/1] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [17:10:08] [Step 1/1] at java.lang.reflect.Method.invoke(Method.java:498) [17:10:08] [Step 1/1] at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60) [17:10:08] [Step 1/1] at com.sun.proxy.$Proxy0.execute(Unknown Source) [17:10:08] [Step 1/1] at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233) [17:10:08] [Step 1/1] at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151) [17:10:08] [Step 1/1] at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123) [17:10:08] [Step 1/1] at org.sonarsource.scanner.cli.Main.execute(Main.java:77) [17:10:08] [Step 1/1] at org.sonarsource.scanner.cli.Main.main(Main.java:61) [17:10:08] [Step 1/1] ERROR: [17:10:08] [Step 1/1] ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging. [17:10:08] [Step 1/1] The SonarQube Scanner did not complete successfully [17:10:08] [Step 1/1] 17:09:24.395 Creating a summary markdown file... [17:10:08] [Step 1/1] 17:09:24.399 Post-processing failed. Exit code: 1 [17:10:08] [Step 1/1] Process exited with code 1

I have coded a hotfix to control the rate limits in BitbucketClient.scala class using UniformInterfaceException handlers Unfortunataley, i have never worked with scala programming language, however, Im looking forward to contribute my solution to code reviewers. How could we do it ? :)

Plug-in version, SonarQube version, CI system, build type

Plugin version: 1.2.3 Sonarqube: 6.7.1 Bitbucket cloud

tzoratto commented 6 years ago

Same here, we encounter more and more 429 error code when analyzing our PRs (either when getting the list of PRs or when posting a comment). It's probably due to the growing number of projects and PRs we have but still I wonder if there is something wrong with this plugin or not. We do not have the same issue with other tools of us that communicate with the bitbucket API on a regular basis

vandammeb commented 6 years ago

same here, any update on this?

elineopsommer commented 6 years ago

same here, really blocking for analyzing our PR's, any update on this?

wimdeblauwe commented 6 years ago

Having the same issue, makes our build fail

mrueegg commented 6 years ago

Hi all,

The rate limits of Bitbucket Cloud are documented here: https://confluence.atlassian.com/bitbucket/rate-limits-668173227.html

They are based on the user executing the REST calls (e.g., posting an issue pull request comment) for authenticated access or based on the IP for unauthenticated calls. If you are using OAuth for this plug-in with the same user for all your repositories, you will reach the API limit of 1000 calls per hour pretty quickly.

One possibility to reduce the likelihood of these errors I see is to use different users for the plug-in for different Bitbucket projects. Would that be a feasible workaround?

wimdeblauwe commented 5 years ago

Isn't it an option to put in some retry logic to avoid that the build fails due to this?