Azure / Azure/azure-rest-api-specs
[.github] Add retries to github-script, including HTTP 401
- Dominant language
- TypeSpec
- Stars
- 3.1k
- Forks
- 5.9k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 424
Description
A github action failed with "HTTP 401 Bad credentials":
```
Mon, 12 Jan 2026 17:30:15 GMT [github] GET https://api.github.com/repos/Azure/azure-rest-api-specs/issues/39568/labels?per_page=100
Mon, 12 Jan 2026 17:30:15 GMT [github] load: 7%, used: 842, remaining: 14158, reset: 00:12:21
Mon, 12 Jan 2026 17:30:15 GMT Labels: [ 'TypeSpec' ]
Mon, 12 Jan 2026 17:30:15 GMT [github] GET https://api.github.com/repos/Azure/azure-rest-api-specs/actions/runs?event=pull_request&head_sha=ac6f5fd7498815781e8a0abb92b6124c34aa0e41&per_page=100
Mon, 12 Jan 2026 17:30:15 GMT RequestError [HttpError]: Bad credentials (status: 401)
```
https://github.com/Azure/azure-rest-api-specs/actions/runs/20928819804/job/60134053495?pr=39568#step:3:28
But the credentials are provided by `github-script`, and the worked for another API the same second, so we suspect this was an intermittent service outage.
To protect ourselves, we could enable retries by default (and the status codes to retry) in all our uses of `github-script`:
https://github.com/actions/github-script?tab=readme-ov-file#retries
```yaml
on:
workflow_call:
inputs:
script:
required: true
type: string
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v8
with:
retries: 3
# We *do* want to retry on 401, since our credentials should always be valid,
# and GitHub can occasionally return 401 incorrectly. We shouldn't need to retry
# the other status codes exempt by default: 400, 403, 404, 422
retry-exempt-status-codes: 400, 403, 404, 422
script: ${{ inputs.script }}
```
Contributor guide
Assessment
This issue has not been assessed yet.