fix(transport): propagate SDK errors instead of silent 200-empty#36
Merged
Conversation
Second-wave audit (#33 Tier-2), convergent across two review passes. Six SDK-backed read handlers returned `json(result.data ?? [], 200)` without checking `result.error`. When the OpenCode SDK returned { data: undefined, error } (IPC down, session vanished, OpenCode restarting) the dashboard saw "empty" instead of an error — silent failure, and inconsistent with getSession/updateSession/deleteSession/ postSessionPrompt which already check. Fixed by mirroring the existing deleteSession precedent exactly: - listSessions, getSessionMessages, getSessionDiff, getSessionChildren (sessions.ts), listTools (sdk-proxy.ts), getStatus (system.ts) now inspect result.error: not-found-style → 404 NOT_FOUND; generic → deps.logger.error + 500 SDK_ERROR. Success/empty paths are byte-identical (same `?? []`/`?? {}` fallback, same 200, same CORS). - listSessions/getStatus make two SDK calls — either error now fails cleanly (no half-empty 200). - Extracted sdkErrorMessage() helper from deleteSession's inline logic (behaviorally identical) to avoid duplication. - getSession deliberately untouched (separately tracked on #25). +23 tests. bun test 647/0, tsc clean. Independent fresh-context review: APPROVE, no blocking issues (all 7 checks PASS incl. success-path byte-identical diff). The one nit (unused test import) is fixed here. Refs #33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves the SDK
result.errorconsistency item of #33 (Tier-2; convergent across the domain-logic + silent-failures passes).Six SDK-backed read handlers did
json(result.data ?? [], 200)without checkingresult.error. On SDK failure (IPC down, session vanished, OpenCode restarting) the dashboard rendered "empty" instead of surfacing the error — silent failure, inconsistent withgetSession/updateSession/deleteSession/postSessionPromptwhich already check.Fix — mirrors the existing
deleteSessionprecedent exactlylistSessionsgetSessionMessages/getSessionDiff/getSessionChildrenlogger.errorlistToolslogger.errorgetStatuslogger.error?? []/?? {}fallback, status 200, CORS headers. Only error early-returns were added.deleteSession/postSessionPromptprecedent (404NOT_FOUND/ 500SDK_ERROR) — no new convention.sdkErrorMessage()fromdeleteSession's inline logic (behaviorally identical) to avoid 4× duplication.getSessiondeliberately untouched (its 404-on-any-error is separately tracked on feat: v1.21.0 audit follow-ups — broken lint script + architecture/quality debt (non-security) #25).Testing
logger.errorcalled; not-found → 404; success/empty → original 200 shape unchanged). Independent spy logger per test, non-flaky.bun test647/0 ·bunx tsc --noEmitcleanMerge note
Independent off
main. Touchessystem.ts(getStatus) — open PR #34 also touchessystem.tsbut a different function (rotateAuthToken); non-overlapping hunks → clean 3-way merge in any order.sessions.ts/sdk-proxy.tsdon't overlap #34/#35.Refs #33 (Tier-2, partial — does not close).