AtProtoOAuthClient: dead unreachable 401 checks in PAR, token exchange, refresh #43

Closed
opened 2026-06-22 20:10:25 +00:00 by starsetbyte · 0 comments
Owner

What

Three sites in AtProtoOAuthClient have redundant/unreachable 401 checks after the outer if-else already handles all 400/401 cases:

  • beginLogin() line 164 — outer if caught 400||401, inner if caught use_dpop_nonce, so line 164 is always-true
  • completeLogin() line 254 — same pattern
  • refreshSession() lines 313+316-319 — same outer pattern plus a second unreachable 401 block after the first

Fix

Removed the redundant 401-only checks. Now all three sites use a single throw after the use_dpop_nonce retry path:

if (body.contains("use_dpop_nonce")) { /* retry */ }
throw IOException("... ${response.code} $body")

Fixed in PR #36.

## What Three sites in `AtProtoOAuthClient` have redundant/unreachable 401 checks after the outer if-else already handles all 400/401 cases: - `beginLogin()` line 164 — outer if caught 400||401, inner if caught use_dpop_nonce, so line 164 is always-true - `completeLogin()` line 254 — same pattern - `refreshSession()` lines 313+316-319 — same outer pattern plus a second unreachable 401 block after the first ## Fix Removed the redundant 401-only checks. Now all three sites use a single `throw` after the use_dpop_nonce retry path: ```kotlin if (body.contains("use_dpop_nonce")) { /* retry */ } throw IOException("... ${response.code} $body") ``` **Fixed in PR #36.**
starsetbyte 2026-06-22 20:10:25 +00:00
Sign in to join this conversation.
No description provided.