Skip to content

Create Review Request - transform string params to a list#3099

Merged
EnricoMi merged 3 commits intoPyGithub:mainfrom
a-sido:single-review-request-fix
Feb 14, 2025
Merged

Create Review Request - transform string params to a list#3099
EnricoMi merged 3 commits intoPyGithub:mainfrom
a-sido:single-review-request-fix

Conversation

@a-sido
Copy link
Copy Markdown
Contributor

@a-sido a-sido commented Dec 25, 2024

Problem

pull_request.create_review_request(reviewers="some-reviewer") raises a GithubException if a single reviewer is provided as a string. This occurs because GitHub expects the reviewers property to be an array, not a single string (Github docs).

Exception example:

github.GithubException.GithubException: 422 {"message": "Invalid request.
For 'properties/reviewers', \"some-reviewer\" is not an array.", "documentation_url": "https://docs.github.com/rest/pulls/review-requests#request-reviewers-for-a-pull-request", "status": "422"}

Fix

Wrap the string arguments (reviewers, team_reviewers) into a list when a single reviewer is provided. This ensures compatibility with GitHub's API, which expects the reviewers property to always be an array.

Fixes #3089

Copy link
Copy Markdown
Collaborator

@EnricoMi EnricoMi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@EnricoMi
Copy link
Copy Markdown
Collaborator

EnricoMi commented Feb 3, 2025

Looks like test data have to be adjusted. It is sufficient to edit them by hand, e.g.:
https://github.com/PyGithub/PyGithub/blob/main/tests/ReplayData/PullRequest.testReviewRequests.txt#L7

@a-sido
Copy link
Copy Markdown
Contributor Author

a-sido commented Feb 8, 2025

Thank you @EnricoMi, adjusted

@EnricoMi EnricoMi added this pull request to the merge queue Feb 14, 2025
Merged via the queue into PyGithub:main with commit 8aef11c Feb 14, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pull Request - Create Review Request (Single Reviewer)

2 participants