Skip to content

Comments

Patch create_dispatch#383

Merged
S1ro1 merged 1 commit intomainfrom
patch-create-dispatch
Dec 19, 2025
Merged

Patch create_dispatch#383
S1ro1 merged 1 commit intomainfrom
patch-create-dispatch

Conversation

@S1ro1
Copy link
Member

@S1ro1 S1ro1 commented Dec 19, 2025

github decided to return 200 instead of 204 as success now, lib isn't updated

Copilot AI review requested due to automatic review settings December 19, 2025 07:04
@S1ro1 S1ro1 merged commit 81201cd into main Dec 19, 2025
5 of 9 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_dispatch function that replicates PyGithub's Workflow.create_dispatch method with updated status code handling
  • Updated the GitHubRun.trigger method 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
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
return status == 200
return status in (200, 204)

Copilot uses AI. Check for mistakes.
workflow.create_dispatch, self.branch, inputs=inputs_with_run_id
)
patched_create_dispatch, workflow, self.branch, inputs=inputs_with_run_id
) # noqa: E501
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
) # noqa: E501
)

Copilot uses AI. Check for mistakes.
Comment on lines +187 to +189
"""
:calls: `POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches <https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event>`_
"""
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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

Successfully merging this pull request may close these issues.

1 participant