DUP-TS-1: 20 raw fetch calls bypass postJSON in api.ts #38

Closed
opened 2026-05-27 16:56:38 +02:00 by dries · 0 comments
Owner

Summary

20 POST methods in frontend/src/lib/api.ts use raw fetch() + if (!resp.ok) throw new Error(...) instead of the existing postJSON helper.

Affected methods include: archiveSession, markSessionSeen, pinSession, calcCost, addFavorite, removeFavorite, respondPermission, respondQuestion, rejectQuestion, abortSession, tmuxSwitch, tmuxLaunchOpencode, worktree.createAndLaunch, compactSession, executeCommand, runShell, renameSession, setAutoApprove, setPromptSections, and others.

Problem

Raw callers miss AuthError propagation — 401s surface as a generic Error instead of AuthError, breaking the auth fan-out.

Fix

Migrate all raw POST callers to the postJSON helper (~lines 171–200) which already has perf-ring instrumentation and 401 fan-out.

Effort

Low — mostly mechanical substitution.

## Summary 20 POST methods in `frontend/src/lib/api.ts` use raw `fetch()` + `if (!resp.ok) throw new Error(...)` instead of the existing `postJSON` helper. Affected methods include: `archiveSession`, `markSessionSeen`, `pinSession`, `calcCost`, `addFavorite`, `removeFavorite`, `respondPermission`, `respondQuestion`, `rejectQuestion`, `abortSession`, `tmuxSwitch`, `tmuxLaunchOpencode`, `worktree.createAndLaunch`, `compactSession`, `executeCommand`, `runShell`, `renameSession`, `setAutoApprove`, `setPromptSections`, and others. ## Problem Raw callers miss `AuthError` propagation — 401s surface as a generic `Error` instead of `AuthError`, breaking the auth fan-out. ## Fix Migrate all raw POST callers to the `postJSON` helper (~lines 171–200) which already has perf-ring instrumentation and 401 fan-out. ## Effort Low — mostly mechanical substitution.
dries closed this issue 2026-07-11 11:23:17 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dries/ocman#38
No description provided.