Commit b1def4f
refactor(oauth): fix backoff bug and clean up error handling (#17)
* refactor(oauth): fix backoff bug and clean up error handling
- Use additive 5s backoff per RFC 8628 §3.5 instead of compounding multiplier
- Replace direct error equality with errors.Is() for ErrRefreshTokenExpired
- Remove duplicate APICallOK() call on re-auth retry path
- Use full struct assignment instead of partial field copies in auto-refresh
- Drain response body before 401 retry to allow connection pool reuse
- Remove unused DeviceAuthURL and Scopes from oauth2.Config
- Replace panic() with fmt.Fprintf + os.Exit(1) in initConfig()
- Replace custom contains() helpers with strings.Contains() in tests
- Update slow_down test for additive backoff behavior
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(review): address PR feedback from Copilot review
- Fix double-close of response body by using explicit close in 401 path
and defer in else branch instead of unconditional defer
- Increase slow_down test timeout from 15s to 25s to prevent flakiness
- Update pollForTokenWithProgress doc comment to say "additive backoff"
instead of "exponential backoff"
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent bfe4d22 commit b1def4f
3 files changed
Lines changed: 35 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
| 184 | + | |
| 185 | + | |
185 | 186 | | |
186 | 187 | | |
187 | 188 | | |
| |||
387 | 388 | | |
388 | 389 | | |
389 | 390 | | |
390 | | - | |
| 391 | + | |
391 | 392 | | |
392 | 393 | | |
393 | 394 | | |
| |||
401 | 402 | | |
402 | 403 | | |
403 | 404 | | |
404 | | - | |
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
| |||
477 | 477 | | |
478 | 478 | | |
479 | 479 | | |
| 480 | + | |
| 481 | + | |
480 | 482 | | |
481 | 483 | | |
482 | 484 | | |
483 | | - | |
484 | | - | |
| 485 | + | |
485 | 486 | | |
486 | | - | |
487 | 487 | | |
488 | 488 | | |
489 | 489 | | |
| |||
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
530 | | - | |
| 530 | + | |
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
| |||
540 | 540 | | |
541 | 541 | | |
542 | 542 | | |
543 | | - | |
| 543 | + | |
544 | 544 | | |
545 | | - | |
546 | 545 | | |
547 | 546 | | |
548 | 547 | | |
| |||
572 | 571 | | |
573 | 572 | | |
574 | 573 | | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
| 574 | + | |
| 575 | + | |
581 | 576 | | |
582 | 577 | | |
583 | 578 | | |
| |||
829 | 824 | | |
830 | 825 | | |
831 | 826 | | |
832 | | - | |
833 | 827 | | |
834 | | - | |
| 828 | + | |
| 829 | + | |
835 | 830 | | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
836 | 834 | | |
837 | 835 | | |
838 | 836 | | |
839 | 837 | | |
840 | 838 | | |
841 | | - | |
| 839 | + | |
842 | 840 | | |
843 | 841 | | |
844 | 842 | | |
845 | 843 | | |
846 | 844 | | |
847 | 845 | | |
848 | 846 | | |
849 | | - | |
850 | | - | |
851 | | - | |
| 847 | + | |
852 | 848 | | |
853 | 849 | | |
854 | 850 | | |
| |||
869 | 865 | | |
870 | 866 | | |
871 | 867 | | |
| 868 | + | |
| 869 | + | |
872 | 870 | | |
873 | 871 | | |
874 | 872 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
271 | 272 | | |
272 | 273 | | |
273 | 274 | | |
274 | | - | |
| 275 | + | |
275 | 276 | | |
276 | 277 | | |
277 | 278 | | |
| |||
285 | 286 | | |
286 | 287 | | |
287 | 288 | | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | 289 | | |
304 | 290 | | |
305 | 291 | | |
| |||
526 | 512 | | |
527 | 513 | | |
528 | 514 | | |
529 | | - | |
| 515 | + | |
530 | 516 | | |
531 | 517 | | |
532 | 518 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | | - | |
83 | | - | |
| 82 | + | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
| 94 | + | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
129 | 131 | | |
130 | 132 | | |
131 | 133 | | |
| |||
137 | 139 | | |
138 | 140 | | |
139 | 141 | | |
140 | | - | |
141 | | - | |
| 142 | + | |
| 143 | + | |
142 | 144 | | |
143 | 145 | | |
144 | 146 | | |
145 | | - | |
| 147 | + | |
146 | 148 | | |
147 | | - | |
| 149 | + | |
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
| |||
0 commit comments