Skip to content

Commit 9fecf5a

Browse files
authored
chore: add alternate "rate limit exceeded" error handling (#494)
The existing handling with the message "API rate limit exceeded..." catches some errors, but we're now seeing errors like "API rate limit already exceeded...", which are causing SLO warnings.
1 parent 9ec1f11 commit 9fecf5a

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

pkg/github/client/errorsourcehandling.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var (
2020
"Resource protected by organization SAML enforcement",
2121
"Resource not accessible by personal access token",
2222
"API rate limit exceeded",
23+
"API rate limit already exceeded",
2324
"Resource not accessible by integration", // issue with incorrectly set permissions for token/app
2425
}
2526
)

pkg/github/client/errorsourcehandling_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ func TestAddErrorSourceToError(t *testing.T) {
8181
resp: nil,
8282
expected: backend.DownstreamError(errors.New("API rate limit exceeded for ID 1")),
8383
},
84+
{
85+
name: "limit exceeded error message",
86+
err: errors.New("API rate limit already exceeded for ID 2"),
87+
resp: nil,
88+
expected: backend.DownstreamError(errors.New("API rate limit already exceeded for ID 2")),
89+
},
8490
{
8591
name: "permission error message",
8692
err: errors.New("Resource not accessible by integration"),

pkg/github/testdata/stargazers.golden.jsonc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
// }
1010
// Name: stargazers
1111
// Dimensions: 8 Fields by 3 Rows
12-
// +-------------------------------+------------------+----------------+----------------+----------------+----------------+----------------------------+---------------------------------------------+
13-
// | Name: starred_at | Name: star_count | Name: id | Name: login | Name: git_name | Name: company | Name: email | Name: url |
14-
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
15-
// | Type: []time.Time | Type: []int64 | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string |
16-
// +-------------------------------+------------------+----------------+----------------+----------------+----------------+----------------------------+---------------------------------------------+
17-
// | 2023-01-14 10:21:41 +0000 GMT | 3 | NEVER | gonna | Run | Around | [email protected] | https://www.youtube.com/watch?v=dQw4w9WgXcQ |
18-
// | 2023-01-14 10:23:41 +0000 GMT | 2 | NEVER | gonna | Let | You | [email protected] | |
19-
// | 2023-01-14 10:25:41 +0000 GMT | 1 | NEVER | gonna | Give | You | [email protected] | |
20-
// +-------------------------------+------------------+----------------+----------------+----------------+----------------+----------------------------+---------------------------------------------+
12+
// +---------------------------------+------------------+----------------+----------------+----------------+----------------+----------------------------+---------------------------------------------+
13+
// | Name: starred_at | Name: star_count | Name: id | Name: login | Name: git_name | Name: company | Name: email | Name: url |
14+
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
15+
// | Type: []time.Time | Type: []int64 | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string |
16+
// +---------------------------------+------------------+----------------+----------------+----------------+----------------+----------------------------+---------------------------------------------+
17+
// | 2023-01-14 10:21:41 +0000 +0000 | 3 | NEVER | gonna | Run | Around | [email protected] | https://www.youtube.com/watch?v=dQw4w9WgXcQ |
18+
// | 2023-01-14 10:23:41 +0000 +0000 | 2 | NEVER | gonna | Let | You | [email protected] | |
19+
// | 2023-01-14 10:25:41 +0000 +0000 | 1 | NEVER | gonna | Give | You | [email protected] | |
20+
// +---------------------------------+------------------+----------------+----------------+----------------+----------------+----------------------------+---------------------------------------------+
2121
//
2222
//
2323
// 🌟 This was machine generated. Do not edit. 🌟

0 commit comments

Comments
 (0)