github / lock

Lock Action to support deployment locking for the branch-deploy Action
MIT License
31 stars 5 forks source link

Bug: Errors are raised if a lock branch is not found #45

Closed GrantBirki closed 5 months ago

GrantBirki commented 5 months ago

Errors are raised if a lock branch is not found

In its current state, this Action throws an error if a lock branch is not found. When originally writing this Action, this made sense to me because if the lock branch is created by this Action, or the parent github/branch-deploy Action, then it should also be removed by it right?... Wrong.

There are now many bespoke ways that other workflows can integrate with this Action. There are also alternate workflows within the github/branch-deploy Action as well such as the Unlock on Merge strategy.

Here is an example of the github/lock Action raising an exception in a workflow when a lock branch is not found:

Image

Due to this error being raised, the entire workflow fails. Rather than failing the entire workflow, it should simply be aware of this edge case, and log a warning message when it occurs.


Error text:

/home/runner/work/_actions/github/lock/v2.1.4/src/functions/unlock.js:116
      throw new Error(error)
^
Error: HttpError: Reference does not exist - https://docs.github.com/rest/git/refs#delete-a-reference
    at unlock (/home/runner/work/_actions/github/lock/v2.1.4/src/functions/unlock.js:116:1)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at run (/home/runner/work/_actions/github/lock/v2.1.4/src/main.js:49:1)
Error: Error: HttpError: Reference does not exist - https://docs.github.com/rest/git/refs#delete-a-reference
    at unlock (/home/runner/work/_actions/github/lock/v2.1.4/src/functions/unlock.js:116:1)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at run (/home/runner/work/_actions/github/lock/v2.1.4/src/main.js:49:1)
Error: HttpError: Reference does not exist - https://docs.github.com/rest/git/refs#delete-a-reference
GrantBirki commented 5 months ago

Good news, it looks like this is already being done, but perhaps the API has changed in a way where this condition is no longer being met. (i.e. octokit raising a custom error class rather than returning status codes, etc)

https://github.com/github/lock/blob/fdcc90adf47eaeecb8bb0aa43f1ad73889a7db2b/src/functions/unlock.js#L92

GrantBirki commented 5 months ago

This issue is officially just me thinking out load and looping back on a problem I already fixed else where 🤦

https://github.com/github/branch-deploy/issues/249