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

Failed to create a pr review comment #2501

Closed
williamfzc opened this issue Apr 19, 2023 · 2 comments
Closed

Failed to create a pr review comment #2501

williamfzc opened this issue Apr 19, 2023 · 2 comments

Comments

@williamfzc
Copy link

hi
I am trying to create pr review comments but getting this error:

Traceback (most recent call last):
  File "/action_internal/main.py", line 173, in <module>
    main()
  File "/action_internal/main.py", line 169, in main
    send_code_comments(repo_token, after_sha, repo_name, int(issue_number), lines)
  File "/action_internal/comment.py", line 35, in send_code_comments
    pr.create_review_comment(
  File "/usr/lib/python3.10/site-packages/github/PullRequest.py", line 431, in create_review_comment
    headers, data = self._requester.requestJsonAndCheck(
  File "/usr/lib/python3.10/site-packages/github/Requester.py", line 398, in requestJsonAndCheck
    return self.__check(
  File "/usr/lib/python3.10/site-packages/github/Requester.py", line 423, in __check
    raise self.__createException(status, responseHeaders, output)
github.GithubException.GithubException: 422 {"message": "Validation Failed", "errors": [{"resource": "PullRequestReviewComment", "code": "custom", "field": "pull_request_review_thread.end_commit_oid", "message": "pull_request_review_thread.end_commit_oid is not part of the pull request"}, {"resource": "PullRequestReviewComment", "code": "missing_field", "field": "pull_request_review_thread.diff_hunk"}], "documentation_url": "https://docs.github.com/rest/reference/pulls#create-a-review-comment-for-a-pull-request"}

It seems that some object defs were out-of-dated.

post_parameters = {

post_parameters = {
            "body": body,
            "commit_id": commit_id._identity,
            "path": path,
            "position": position,
        }

https://docs.github.com/en/rest/pulls/comments?apiVersion=2022-11-28#create-a-review-comment-for-a-pull-request

The official doc said position is deprecated. Use line instead.

@heitorpolidoro
Copy link
Contributor

Hi,

I created this pull request #2540 that might fix this issue

@EnricoMi
Copy link
Collaborator

This has been fixed in #2540.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants