This repository has been archived by the owner on Aug 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
404 error because trying to update a deleted comment #110
Comments
oosterad
changed the title
404 error because comment id cannot be found in bitbucket
404 error because trying to update a deleted comment
Oct 25, 2019
I believe I have been running into this issue as well, thank you for your effort in implementing a solution! |
You're welcome! |
Confirmed the fix works for me. |
@thuypt I would like to make a PR, but I cannot make a branch (or do not know how to do it). And since I got totally no response back then, I decided to create a fork instead. |
@oosterad I couldn't find the repo's contribution policy. But by taking a look at the recent PRs list, people created PRs from their fork repo(any branch) to |
We have the same issue here |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Expected Behavior
I expected the comments from the sonar PR analysis to successfully be sent to bitbucket.
Cause of the problem
The plugin deletes comments when the sonar problem on that line has disappeared. However, a comment is not really deleted, but bitbucket sets the flag "deleted" to true. when a new problem arises on the same line, the plugin does not detect this and tries to update this comment which is not allowed because it is deleted.
Possible solution
Extend the PullRequestComment class with an isDeleted property.
In the method fetchPullRequestCommentsPage set this property.
In the method processExistingComments filter not only on isInLine, but add filtering on !isDeleted.
This way a new comment will be created instead of updating a deleted one.
I have implement this, code can be found here and the release here.
Actual Behavior
First few runs it works as expected and I see my sonar comments in the PR, but then suddenly after a new commit I get the following error:
Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.1.1688:sonar (default-cli) on project my-project-name: PUT https://api.bitbucket.org/2.0/repositories/myname/my-repo-slug/pullrequests/174/comments/115431040 returned a response status of 404 Not Found
and
Caused by: com.sun.jersey.api.client.UniformInterfaceException: PUT https://api.bitbucket.org/2.0/repositories/crv4all/fertility-domain/pullrequests/174/comments/115431040 returned a response status of 404 Not Found at com.sun.jersey.api.client.WebResource.voidHandle (WebResource.java:707) at com.sun.jersey.api.client.WebResource.access$400 (WebResource.java:74) at com.sun.jersey.api.client.WebResource$Builder.put (WebResource.java:517) at ch.mibex.bitbucket.sonar.client.BitbucketClient.updateReviewComment (BitbucketClient.scala:263) at ch.mibex.bitbucket.sonar.review.ReviewCommentsHandler.ch$mibex$bitbucket$sonar$review$ReviewCommentsHandler$$updateComment (ReviewCommentsHandler.scala:148) at ch.mibex.bitbucket.sonar.review.ReviewCommentsHandler$$anonfun$updateComments$1$$anonfun$apply$1.apply (ReviewCommentsHandler.scala:43) at ch.mibex.bitbucket.sonar.review.ReviewCommentsHandler$$anonfun$updateComments$1$$anonfun$apply$1.apply (ReviewCommentsHandler.scala:37)
Plug-in version, SonarQube version, CI system, build type
Latest plug-in version, 1.3.0
Running from Jenkins.
SonarQube 7.2.1
Additional information
The sonar analysis runs fine according to the following logging:
[INFO] ANALYSIS SUCCESSFUL [INFO] Executing post-job Sonar Plug-in for Bitbucket Cloud [INFO] [sonar4bitbucket] Plug-in is active and will analyze pull request #174...
When I do a GET (using Postman) of this comment, everything works fine:
https://api.bitbucket.org/2.0/repositories/myname/my-repo-slug/pullrequests/174/comments/115431040
However when I do a PUT with this in the body:
{ "content": { "raw": "Test of oosterad" } }
I get exactly the same result. A 404 and the following json:
{ "type": "error", "error": { "message": "115431040" } }
Regards,
Ad
The text was updated successfully, but these errors were encountered: