vsoch / pull-request-action

open a pull request when a branch is pushed or updated
https://github.com/marketplace/actions/pull-request-action
MIT License
173 stars 62 forks source link

422 Unprocessable Entity on opening PR #86

Closed hui1110 closed 2 years ago

hui1110 commented 2 years ago

After creating a pull request, I added the variable PASS_IF_EXISTS, try to update the pull request, there will be the following print:

Unable to create pull request: 422: Unprocessable Entity
 {'message': 'Validation Failed', 'errors': [{'resource': 'PullRequest', 'code': 'custom', 'message': 'A pull request already exists for ***:branch_name.'}], 'documentation_url': 'https://docs.github.com/rest/reference/pulls#create-a-pull-request'}
...
...
Params for checking if pull request exists: {'base': 'main', 'head': '***:branch_name', 'state': 'open'}
No pull request from ***:branch_name to main is open, continuing!
Data for opening pull request: {'title': '', 'body': '.', 'base': 'main', 'head': '***:branch_name', 'draft': True, 'maintainer_can_modify': True}
...

The variable PASS_IF_EXISTS doesn't seem to work.

vsoch commented 2 years ago

PASS_IF_EXISTS is only relevant if you already have the PR and want the test to pass: https://github.com/vsoch/pull-request-action/blob/e64deeba68463798e4438d116312934afcd2d74a/pull-request.py#L326-L328

The error you are linking is triggered up here: https://github.com/vsoch/pull-request-action/blob/e64deeba68463798e4438d116312934afcd2d74a/pull-request.py#L110-L112 and it suggests that the GitHub API doesn't like the formatting of some of your parameters.

vsoch commented 2 years ago

Also this line suggests you made it through that second part:

No pull request from ***:branch_name to main is open, continuing!

I'm suspicious about your title and body being empty (or a .) - I would try actually putting some content there. If that still doesn't work, try removing special characters from your branch name (I think I see a :)

hui1110 commented 2 years ago

Thanks for your reply, this has been fixed. The parameter does not conform to the format of the GitHub API.

vsoch commented 2 years ago

Sure thing! I've definitely hit this issue before too. If you are all set please feel free to close the issue.