Commit 14e2653
refactor(oauth): deduplicate token parsing and fix struct copy bug (#12)
* refactor(oauth): deduplicate token parsing and fix struct copy bug
- Extract shared tokenResponse struct and parseOAuthError helper to eliminate duplicate error parsing
- Simplify PKCE branching to always set code_verifier unconditionally
- Fix incomplete struct copy in makeAPICallWithAutoRefresh using full struct assignment
- Drain response body on 401 to allow HTTP connection reuse
- Replace time.After with time.NewTimer to prevent timer leak
- Extract quitInterrupted method to deduplicate interrupt-handling blocks
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(oauth): address PR review feedback for error handling and connection reuse
- Add errResp.Error != "" guard in refreshAccessToken to avoid empty error messages when JSON unmarshals successfully but contains no OAuth error
- Close response body immediately after draining on 401 so the HTTP transport can reuse the connection for the retry request
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 97a37a8 commit 14e2653
3 files changed
Lines changed: 50 additions & 54 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
| |||
143 | 146 | | |
144 | 147 | | |
145 | 148 | | |
146 | | - | |
| 149 | + | |
147 | 150 | | |
148 | 151 | | |
149 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
207 | 226 | | |
208 | 227 | | |
209 | 228 | | |
| |||
317 | 336 | | |
318 | 337 | | |
319 | 338 | | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
325 | 342 | | |
326 | | - | |
327 | 343 | | |
328 | 344 | | |
329 | 345 | | |
| |||
349 | 365 | | |
350 | 366 | | |
351 | 367 | | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
| 368 | + | |
361 | 369 | | |
362 | 370 | | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
| 371 | + | |
370 | 372 | | |
371 | 373 | | |
372 | 374 | | |
| |||
427 | 429 | | |
428 | 430 | | |
429 | 431 | | |
| 432 | + | |
430 | 433 | | |
431 | | - | |
| 434 | + | |
432 | 435 | | |
433 | 436 | | |
434 | 437 | | |
435 | 438 | | |
436 | 439 | | |
437 | | - | |
| 440 | + | |
438 | 441 | | |
439 | 442 | | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
| 443 | + | |
446 | 444 | | |
447 | 445 | | |
448 | 446 | | |
| |||
498 | 496 | | |
499 | 497 | | |
500 | 498 | | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
| 499 | + | |
506 | 500 | | |
507 | 501 | | |
508 | 502 | | |
| |||
523 | 517 | | |
524 | 518 | | |
525 | 519 | | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
526 | 524 | | |
527 | 525 | | |
528 | 526 | | |
| |||
531 | 529 | | |
532 | 530 | | |
533 | 531 | | |
534 | | - | |
535 | | - | |
536 | | - | |
| 532 | + | |
537 | 533 | | |
538 | 534 | | |
539 | 535 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
200 | | - | |
201 | | - | |
| 199 | + | |
202 | 200 | | |
203 | 201 | | |
204 | 202 | | |
| |||
216 | 214 | | |
217 | 215 | | |
218 | 216 | | |
219 | | - | |
220 | | - | |
221 | | - | |
| 217 | + | |
222 | 218 | | |
223 | 219 | | |
224 | 220 | | |
| |||
246 | 242 | | |
247 | 243 | | |
248 | 244 | | |
249 | | - | |
250 | | - | |
251 | | - | |
| 245 | + | |
252 | 246 | | |
253 | 247 | | |
254 | 248 | | |
| |||
267 | 261 | | |
268 | 262 | | |
269 | 263 | | |
270 | | - | |
271 | | - | |
272 | | - | |
| 264 | + | |
273 | 265 | | |
274 | 266 | | |
275 | 267 | | |
| |||
283 | 275 | | |
284 | 276 | | |
285 | 277 | | |
286 | | - | |
287 | | - | |
288 | | - | |
| 278 | + | |
289 | 279 | | |
290 | 280 | | |
291 | 281 | | |
| |||
324 | 314 | | |
325 | 315 | | |
326 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
0 commit comments