Post comment on a commit/pull request API does not work when line_to parameter points to a white line

Issue #13110 open
Gideon Koh
created an issue

The post comment on a commit/pull request API does not work when the line_to parameter is pointing to a white line.

Recent activity will show that a comment is added, but the comment is nowhere to be seen.

line_from parameter works correctly on a white line.

Comments (6)

  1. Steve Ramage

    If I create a pull request and try and comment with the API, there are two sets of line numbers available line_from and line_to. The line_from references lines in white and red, and lines_to references lines in white and green. However it seems that if I want to introduce a comment on a white line, if I do so with line_to the comment is lost. The effect is subtle, in fact the first day I didn't notice it.

    If you have a PR open, you will be notified via an AJAX call presumably that there is a new change (with the users avatar and a number). If you click that the comment appears. If you go to the Activity page it says "[User] commented on a file but no context is available." If you refresh the page the comment disappears. There is still a number next to the file name indicating that there are comments, but they do not render. Furthermore in the e-mail notification I just see the comment, and the file name but no line numbers are rendered when using line_to, with line_from I get the full context included inline in the e-mail.

    //Works fine curl -u "user:pass" -H "Content-Type: application/json" -d ' { "content" : "Test Comment", "line_from": 110, "filename" : "somefile.java" } ' https://api.bitbucket.org/1.0/repositories/somerepo/someurl/pullrequests/id/comments

    //Has weirdness, only shows up in activity. curl -u "user:pass" -H "Content-Type: application/json" -d ' { "content" : "Test Comment", "line_to": 110, "filename" : "somefile.java" } ' https://api.bitbucket.org/1.0/repositories/somerepo/someurl/pullrequests/id/comments

  2. Kaleb Elwert
    • changed status to open

    I feel like this is mostly a documentation issue. It should be line_from when you're commenting on a non-changed line. That's how we store it internally.

    It might also be possible to translate that so we can accept either and store it as line_from internally.

  3. Steve Ramage

    Kaleb, it seems odd that the e-mails are generated notifying everyone. And it gets documented in the Activity, then just disappears. Additionally I don't know that I would agree with that, sometimes from an API perspective making comments you only know an unmodified line to. And you need to make a comment. If line 10 was modified, and line 15 wasn't but line 15 contains pertinent info, I shouldn't have to translate that to the line_from.

  4. Pavel

    Any update on this issue? Right now its not so easy to add a comment via API to commits from CI tools. For example, we could take a line number from some report, which generated from a new (changed) file, but we could know which line we should use from the old original file.

  5. Log in to comment