Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a breaking change in the GitHub API where workflow dispatch requests now return status code 200 instead of 204. Since the PyGithub library hasn't been updated to handle this change, the PR implements a patched version of create_dispatch that checks for the new status code.
Key Changes:
- Added a
patched_create_dispatchfunction that replicates PyGithub'sWorkflow.create_dispatchmethod with updated status code handling - Updated the
GitHubRun.triggermethod to use the patched function instead of the original library method
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| status, _, _ = workflow._requester.requestJson( | ||
| "POST", f"{workflow.url}/dispatches", input={"ref": ref, "inputs": inputs} | ||
| ) | ||
| return status == 200 |
There was a problem hiding this comment.
The patched function only accepts status code 200, but according to the PR description, GitHub previously returned 204. To maintain backward compatibility and handle both old and new API behavior, consider accepting both status codes. This would prevent issues if GitHub reverts the change or if different GitHub API versions are used.
| return status == 200 | |
| return status in (200, 204) |
| workflow.create_dispatch, self.branch, inputs=inputs_with_run_id | ||
| ) | ||
| patched_create_dispatch, workflow, self.branch, inputs=inputs_with_run_id | ||
| ) # noqa: E501 |
There was a problem hiding this comment.
The noqa: E501 comment suppresses line-too-long warnings, but this line appears to be under the 100-character limit specified in .ruff.toml. Consider removing this comment if the line length is within the project's limits.
| ) # noqa: E501 | |
| ) |
| """ | ||
| :calls: `POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches <https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event>`_ | ||
| """ |
There was a problem hiding this comment.
The docstring should explain why this patched version exists and what issue it addresses. Consider adding a note that this patches the PyGithub library to handle GitHub API's change from returning 204 to 200 status codes.
github decided to return 200 instead of 204 as success now, lib isn't updated