octokit / plugin-retry.js

Octokit plugin for GitHub’s recommended request retries
MIT License
36 stars 18 forks source link

[FEAT]: possibility to override errorRequest #499

Open stromnet opened 9 months ago

stromnet commented 9 months ago

Describe the need

doNotRetry only supports checking on status code. This is not enough in some cases.

For example, I have a flow where I create a new repository and then make some additional calls, setting team permissions adding topics etc. Sometimes those follow-up calls fails with 422 and an error like this:

{
  message: 'Validation Failed',
  errors: [
    {
      resource: 'TeamRepository',
      code: 'unprocessable',
      field: 'data',
      message: 'This repository is locked and cannot be modified.'
    }
  ],
  documentation_url: 'https://docs.github.com/rest/teams/teams#add-or-update-team-repository-permissions'
}

While it does not make sense to always retry 422, it would perhaps make sense to do it if code is 422 and message contains this "is locked". In some cases, not all perhaps. Because repos could really be locked too. But in my case I know it wont be. If I would be able to specify my custom logic, I could tailor it for my needs. Atm I instead opt to clone all code, just to change that logic.

Regarding this particular case, GitHub support have replied that this is expected (https://support.github.com/ticket/personal/0/2465057 if you has access to internal tickets):

It can take time for replication of data, and we lock the repositories during creation and changes to permissions, as you've noted. It really depends on the current load. We recommend retrying with exponential backoff in such situations.

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

github-actions[bot] commented 9 months ago

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀