Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/fast-revert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@ jobs:
token: ${{ steps.token.outputs.token }}

- name: comment on failure
env:
GH_TOKEN: ${{ steps.token.outputs.token }}
GH_REPOSITORY: ${{ github.repository }}
GH_RUN_ID: ${{ github.run_id }}
GH_REPO_ID: ${{ github.event.repository.id }}
PR_NUMBER: ${{ github.event.number || github.event.inputs.pr }}
run: |
curl \
--silent \
-X POST \
-H 'Authorization: token ${{ steps.token.outputs.token }}' \
-d'{"body": "revert failed (conflict? already reverted?) -- [check the logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"}' \
https://api.github.com/repositories/${{ github.event.repository.id }}/issues/${{ github.event.number || github.event.inputs.pr }}/comments
-H "Authorization: token $GH_TOKEN" \
-d"{\"body\": \"revert failed (conflict? already reverted?) -- [check the logs](https://github.com/$GH_REPOSITORY/actions/runs/$GH_RUN_ID)\"}" \
"https://api.github.com/repositories/$GH_REPO_ID/issues/$PR_NUMBER/comments"
if: failure()
Comment on lines 49 to 54
Copy link

Choose a reason for hiding this comment

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

Bug: When triggered via workflow_dispatch, the GH_REPO_ID variable is empty, causing the failure notification step to silently fail due to a malformed API URL.
Severity: MEDIUM

Suggested Fix

Ensure the repository ID is correctly sourced for all trigger types. Instead of relying on github.event.repository.id, which is not present in workflow_dispatch events, use the universally available github.repository_id context variable to populate GH_REPO_ID.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: .github/workflows/fast-revert.yml#L49-L54

Potential issue: When the workflow is triggered via `workflow_dispatch`, the
`github.event.repository.id` context variable is unavailable. This results in the
`GH_REPO_ID` environment variable being set to an empty string. Consequently, the
'comment on failure' step constructs a malformed API URL
(`https://api.github.com/repositories//issues/...`) for its `curl` command. This causes
the API call to fail, silently preventing a failure notification comment from being
posted to the pull request if the main revert action fails. This issue only occurs with
the `workflow_dispatch` trigger.

Did we get this right? 👍 / 👎 to inform future reviews.

Loading