Skip to content

Fail the step when the job's token can't post the review comment - #229

Open
reuvenharrison wants to merge 2 commits into
mainfrom
fail-on-blocked-review-comment
Open

reuvenharrison wants to merge 2 commits into
mainfrom
fail-on-blocked-review-comment

Conversation

@reuvenharrison

Copy link
Copy Markdown
Contributor

When the job's token lacks pull-requests: write, GitHub refuses the review comment with HTTP 403 ("Resource not accessible by integration"). Until now the action only printed a warning on a job that still passed, so the comment never appeared and nothing on the pull request said why.

The step now fails with an error naming the fix:

oasdiff couldn't post the PR comment: GitHub refused the comment (HTTP 403) because the job's token can't write to pull requests. Add 'permissions: pull-requests: write' to the job that runs this action, or set 'github-token: ""' on the action to keep the review link in the job summary only.

Unchanged:

  • A pull request from a fork, where GitHub makes the token read-only whatever the job grants, still gets a plain line and passes.
  • Any other refusal (a secondary rate limit, a 5xx) still only warns, since it isn't the job's configuration. The failure is keyed on GitHub's response message, not on the status alone, because a rate limit is also a 403.
  • Runs with no changes never fail on the comment.

This changes the job result for workflows that run the action without the permission, so it belongs in a minor release with an upgrade note.

The anonymous delivery event now also carries the HTTP status of a failed comment.

The test for a blocked comment now covers the missing permission (step fails, exit 1), a rate-limited 403 (warning, step passes) and a fork (plain line). It fails on the current main.

🤖 Generated with Claude Code

reuvenharrison and others added 2 commits November 27, 2026 22:26
When the job's token lacked pull-requests: write, the review comment
failed with only a warning on a passing job, so the comment silently
never appeared. The step now fails with an error naming the permission
to add, or the opt-out (github-token: ''). A pull request from a fork,
where the token is read-only whatever the job grants, still only gets a
plain line, and any other refusal (such as a rate limit) still warns.

The anonymous delivery event now carries GitHub's HTTP status when the
comment fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
These steps check the action's output, not the comment, and the test
workflows don't grant pull-requests: write, so a comment attempt would now
fail them. Set github-token: '' on each, the opt-out the new error names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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