Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 4

"Position is invalid" error in posting PR review via v3 API.

My GitHub app (reviewnb.com) routinely posts review comments for pull request without a problem.

 

There's this specific Pull Request in one of our user's private repos that is literally not accepting any review comment via the API. Following is my payload:

 

{
'body': 'This change looks good!', 
'event': 'COMMENT',
'comments': [
  {
    'body': "<p>Can you edit this line?</p>",
    'path': "competitions/water_pumps/notebooks/EDA_adiel.ipynb", 
    'position': 1
  }]
}

I am posting this payload to:

https://api.github.com/repos/<owner>/<repo>/pulls/<pr_number>/reviews

 

The error I am seeing is:

{'message': 'Unprocessable Entity', 'errors': ['Position is invalid'], 'documentation_url': 'https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review'}

 

So it looked like position 1 is not a valid position to post that comment. Which is incorrect because when I fetch the diff of this PR the file diff shows that there are about 670 lines added in this change. So line number 1 in the diff hunk got to be valid.

 

Anyway, I tried all other numbers for the position parameter. But it returns the same error. 

3 Replies
Pilot Lvl 1
Message 2 of 4

Re: "Position is invalid" error in posting PR review via v3 API.

Hi @amit1rrr

 

Try creating a review comment manually then fetching it via the API to look up its position. I'm guessing that for whatever reason, 1 is an invalid position for that PR.

 

Btw was your website design inspired by my old site (for Pull Reminders)? I don't mind at all, was just curious.

 

Copilot Lvl 3
Message 3 of 4

Re: "Position is invalid" error in posting PR review via v3 API.

Try creating a review comment manually then fetching it via the API to look up its position.

I can't. These are private repositories of our users. I haven't been able to reproduce it on any of my repositories.

 

I'm guessing that for whatever reason, 1 is an invalid position for that PR.

This is the strange part. Diff starts with position 1 , so as long as there is at lease 1 line of diff, position 1 should be valid. Any other ideas / things to test?

 

> Btw was your website design inspired by my old site (for Pull Reminders)? I don't mind at all, was just curious.

I'm aware of Pull Reminders but I don't think I have seen your old site, so no. The design is actually inspired by my other product home page: https://www.nurtch.com/ 

 

 

Copilot Lvl 3
Message 4 of 4

Re: "Position is invalid" error in posting PR review via v3 API.

Wrote to support@github.com and provided them with all the requested information. I got following reply:

 

Thanks, Amit -- that's helpful. I believe that's a problem on our end related to creating comments on diffs that are very large (notice that the diff for the file in question is quite large). With that in mind, I've opened an internal issue so that the team can investigate. I can't promise an ETA, but we'll followup as soon as there's any news.

Best,
GitHub Staff

 

I am following up with them to see,
  1. Specific conditions under which this bug occurs (diff size etc.) and see if I can build some work around while they fix the issue.
  2. Follow up to see when they can fix the underlying root cause.
 
I will update the post when I get further updates.