Fix: handle 403 gracefully on fork PRs in pr_validation#80
Open
hdamker wants to merge 1 commit intocamaraproject:mainfrom
Open
Fix: handle 403 gracefully on fork PRs in pr_validation#80hdamker wants to merge 1 commit intocamaraproject:mainfrom
hdamker wants to merge 1 commit intocamaraproject:mainfrom
Conversation
Wrap createCommitStatus() call in try-catch to handle 403 errors that occur when GITHUB_TOKEN has insufficient permissions for fork PRs. Logs a warning instead of crashing the job. Other errors are re-thrown. Fixes camaraproject#76.
Contributor
Author
|
@rartych that is exactly the reason why some PRs show the Megalinter result other not: the Megalinter is also getting the 403 due to missing write permission, but handles them gracefully, while the release-plan.yaml currently exists with code 1. After the merge, the v0 tag need to be moved. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
bug
What this PR does / why we need it:
The
pr_validationworkflow crashes when a fork PR changesrelease-plan.yaml. ThecreateCommitStatus()API call fails with HTTP 403 becauseGITHUB_TOKENhas insufficient permissions for fork-initiated PRs. The validation itself passes, but the unhandled error causes the job to fail.This wraps the
createCommitStatus()call in a try-catch block. On 403, it logs a warning with the validation result instead of crashing. Other errors are re-thrown. MegaLinter in the same workflow already handles 403s gracefully — this aligns the release-plan validation step.Which issue(s) this PR fixes:
Fixes #76
Special notes for reviewers:
The fix is minimal: only the
createCommitStatus()call is wrapped. The rest of the step (error annotations, job summary,core.setFailed) writes to workflow logs/summary, not to the repo API, so it works fine with fork PR tokens.Changelog input
Additional documentation
This section can be blank.