Skip to content

Failed to create a pr review comment #2501

@williamfzc

Description

@williamfzc

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions