cloudaxe-opencode/packages/opencode/test/server
Kit Langton 98fef45553 fix(httpapi): 404 status + body shape for missing-session errors
Two related divergences from Hono are fixed in one move:

1. Status: many session handlers (todo, diff, summarize, fork, abort,
   init, deleteMessage, command, shell, revert, unrevert) didn't wrap
   with mapNotFound, so a thrown NotFoundError surfaced as a 500 defect
   instead of a 404. The fork/diff endpoints also lacked OpencodeNotFound
   in their declared error union, so handlers couldn't surface 404 even
   if they wanted to.

2. Body shape: the existing mapNotFound rebrand to HttpApiError.NotFound
   produced an empty 404 response. Hono returns the NamedError envelope
   `{ name: "NotFoundError", data: { message } }`. SDK consumers reading
   `error.data.message` got undefined.

The fix introduces OpencodeNotFound — a Schema.ErrorClass annotated with
`httpApiStatus: 404` and a body schema matching the legacy NamedError
shape. mapNotFound now rebrands NotFoundError to OpencodeNotFound,
preserving the underlying error message. All session endpoints that take
a sessionID now wrap their service calls with mapNotFound.

A TODO in the handler notes the long-term direction: services should
fail with typed errors directly (Effect<T, SessionNotFound>) and let
HttpApi auto-route status + body via schema annotations, eliminating
mapNotFound entirely. This PR is the pragmatic middle: small surface,
no service-layer changes, fixes the user-visible parity bug.

Unskips the two .todo parity reproducers in httpapi-parity.test.ts.
2026-05-02 23:33:14 -04:00
..
AGENTS.md test: cover HttpApi instance context middleware (#25032) 2026-04-29 21:24:45 -04:00
global-bus.ts test(httpapi): add route exerciser 2026-05-02 20:31:21 -04:00
global-session-list.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
httpapi-authorization.test.ts refactor: use Effect config for HttpApi authorization (#25035) 2026-04-29 22:22:32 -04:00
httpapi-bridge.test.ts Refactor v2 session events as schemas (#24512) 2026-05-02 22:09:48 -04:00
httpapi-config.test.ts test(httpapi): add route exerciser 2026-05-02 20:31:21 -04:00
httpapi-cors.test.ts chore: generate 2026-05-01 01:28:37 +00:00
httpapi-event.test.ts Refactor v2 session events as schemas (#24512) 2026-05-02 22:09:48 -04:00
httpapi-experimental.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
httpapi-file.test.ts Replace Instance.disposeAll/load with fixture helper (#25418) 2026-05-02 10:56:15 -04:00
httpapi-instance-context.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
httpapi-instance.legacy.test.ts test(httpapi): add route exerciser 2026-05-02 20:31:21 -04:00
httpapi-instance.test.ts Replace Instance.disposeAll/load with fixture helper (#25418) 2026-05-02 10:56:15 -04:00
httpapi-json-parity.test.ts Replace Instance.disposeAll/load with fixture helper (#25418) 2026-05-02 10:56:15 -04:00
httpapi-mcp-oauth.test.ts chore: generate 2026-04-30 15:08:03 +00:00
httpapi-mcp.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
httpapi-parity.test.ts fix(httpapi): 404 status + body shape for missing-session errors 2026-05-02 23:33:14 -04:00
httpapi-provider.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
httpapi-pty-websocket.test.ts test: port instance HttpApi path/vcs read coverage to Effect 2026-04-30 11:07:00 -04:00
httpapi-pty.test.ts Replace Instance.disposeAll/load with fixture helper (#25418) 2026-05-02 10:56:15 -04:00
httpapi-raw-route-auth.test.ts Replace Instance.disposeAll/load with fixture helper (#25418) 2026-05-02 10:56:15 -04:00
httpapi-sdk.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
httpapi-session.test.ts chore: generate 2026-05-03 02:10:52 +00:00
httpapi-sync.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
httpapi-tui.test.ts test(httpapi): add route exerciser 2026-05-02 20:31:21 -04:00
httpapi-ui.test.ts Avoid request-time HttpApi layer provisioning (#25179) 2026-04-30 19:36:57 -04:00
httpapi-workspace-routing.test.ts refactor: rename workspace adapters (#25272) 2026-05-01 07:36:52 -04:00
httpapi-workspace.test.ts Replace Instance.disposeAll/load with fixture helper (#25418) 2026-05-02 10:56:15 -04:00
project-init-git.test.ts Delete Instance.dispose and Instance.reload (#25427) 2026-05-02 11:44:16 -04:00
proxy-util.test.ts Refactor HttpApi workspace routing and proxy boundaries (#25006) 2026-04-29 16:50:54 -04:00
session-actions.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
session-list.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
session-messages.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
session-select.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
trace-attributes.test.ts refactor(server): align route-span attrs with OTel semantic conventions (#23198) 2026-04-18 00:29:26 +00:00
workspace-proxy.test.ts chore: generate 2026-04-30 23:37:58 +00:00
workspace-routing.test.ts Refactor HttpApi workspace routing and proxy boundaries (#25006) 2026-04-29 16:50:54 -04:00