Commit 89fc626
[CXP-204] improve rate limit and temporary error handling (#121)
* fix: improve rate limit and temporary error handling in wrapGitHubError
When go-github blocks requests client-side due to rate limits, it returns
a RateLimitError with a synthetic 403 response that has empty headers.
The existing isRatelimited() check failed because it expects the
X-Ratelimit-Remaining header to equal "0", but the synthetic response
has no headers at all. This caused rate limit errors to be misclassified
as PermissionDenied, which is not retried by the SDK.
Changes:
- Check for *github.RateLimitError and *github.AbuseRateLimitError types
using errors.As() before checking HTTP status codes
- Extract rate limit data (reset time, limit, remaining) from the error
and attach it to the gRPC status details for proper backoff
- Add isTemporarilyUnavailable() to handle 503, 502, and 504 errors
- Return codes.Unavailable for all these cases, enabling SDK retry logic
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: add zero-time check in rateLimitDescriptionFromRate
Prevent creating misleading timestamps when rate.Reset.Time is zero,
matching the defensive pattern used in other rate limit functions.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* remove embedded field
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent 54ab119 commit 89fc626
1 file changed
Lines changed: 69 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
188 | 191 | | |
189 | 192 | | |
190 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
191 | 229 | | |
192 | 230 | | |
193 | 231 | | |
| |||
256 | 294 | | |
257 | 295 | | |
258 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
259 | 306 | | |
260 | 307 | | |
261 | 308 | | |
| |||
264 | 311 | | |
265 | 312 | | |
266 | 313 | | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
267 | 330 | | |
268 | 331 | | |
269 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
270 | 339 | | |
271 | 340 | | |
272 | 341 | | |
| |||
0 commit comments