Skip to content

fix(server): surface the declared 404 when deleting a missing message - #1109

Merged
Astro-Han merged 1 commit into
devfrom
claude/i936-silent-200
Jun 3, 2026
Merged

fix(server): surface the declared 404 when deleting a missing message#1109
Astro-Han merged 1 commit into
devfrom
claude/i936-silent-200

Conversation

@Astro-Han

Copy link
Copy Markdown
Owner

Summary

Part of the staged Effect error-contract migration (#936): turn a silent 200
into the route's already-declared 404.

DELETE /session/:sessionID/message/:messageID (session.deleteMessage)
declares errors(400, 404, 409), but Session.removeMessage was a silent
no-op: it fired MessageV2.Event.Removed and returned the id without checking
existence
, so deleting a message that does not exist returned 200. The
declared 404 was a phantom that never fired.

Change

Session.removeMessage now verifies the message exists first via
MessageV2.get (the same throwing lookup the sibling GET .../message/:messageID
route relies on for its 404). MessageV2.get throws NotFoundError for a
missing row, which ErrorMiddleware maps to 404 (and does not error-log).

Why in the service, not the route: removeMessage is the "delete a message"
domain operation and has exactly one caller — the route handler (no top-level
wrapper) — so putting the existence check there makes the operation correct with
a contained blast radius. assertNotBusy stays in the route, so the ordering is
preserved: a busy session still wins with 409, and only the idle + missing
case flips from a silent 200 to 404.

Behavior change & de-risk

The only change is that deleting a message that does not exist (e.g. a
double-delete, or an unknown id) now returns the already-declared 404 instead
of a misleading 200. The desktop app does not call this endpoint directly —
it reacts to the message.removed SSE event — so there is no frontend impact.
Verified there are no internal callers of removeMessage that relied on the
silent no-op (the full session suite stays green).

Scope (deliberately one route)

This is the first, smallest slice of the silent-200 cleanup. The sibling
candidates are intentionally not bundled, each for a concrete reason:

  • part.deleteremovePart is also reused internally by processor.ts, so its fix must be route-level, not service-level; different shape.
  • permission.reply — separate subsystem with CLI/ACP/test callers; larger surface.
  • experimental.console.switchOrgaccount.use is a blind upsert and the account errors are Effect TaggedErrorClass (not the mapped NamedError); needs new validation + a mapped error type (design).
  • permission.respond — already deprecated and fire-and-forget.

Verification

  • bun test test/server/session-messages.test.ts — 12 pass (new test covers both the 200 success delete and the 404 on a missing id)
  • bun test test/server/ — 332 pass
  • bun test test/session/ — 790 pass / 0 fail (confirms no internal consumer relied on the silent no-op)
  • bun run typecheck — clean

Deferred (known, tracked)

The checked-in packages/sdk/openapi.json snapshot / src/v2/gen types are
regenerated in a single batched resync PR at the end of the #936 series, not
per-slice. No functional impact (the app reacts to SSE, not this response).

Refs #936

The DELETE /session/:sessionID/message/:messageID route declares a 404, but
Session.removeMessage was a silent no-op: it fired MessageV2.Event.Removed and
returned the id without checking existence, so deleting a message that does not
exist returned 200. The declared 404 was a phantom.

Make removeMessage verify the message exists first via MessageV2.get (which
throws NotFoundError for a missing row, mapped to 404 by ErrorMiddleware). The
existence check lives in the service rather than the route because removeMessage
is the "delete a message" domain operation and has exactly one caller (the
route, no top-level wrapper), so the blast radius is contained. assertNotBusy
stays in the route, so a busy session still wins with 409 and only the
idle+missing case flips from a silent 200 to 404.

No frontend impact: the desktop app does not call this endpoint directly (it
reacts to the message.removed SSE event). The only behavior change is that a
double-delete (or deleting an unknown id) now returns the already-declared 404.

Refs #936
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Astro-Han, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 56 minutes and 24 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d29c68ff-a229-479b-992a-0e3e2c313817

📥 Commits

Reviewing files that changed from the base of the PR and between f6a1328 and 4bc845f.

📒 Files selected for processing (2)
  • packages/opencode/src/session/session.ts
  • packages/opencode/test/server/session-messages.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/i936-silent-200

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Astro-Han Astro-Han added bug Something isn't working harness Model harness, prompts, tool descriptions, and session mechanics P2 Medium priority upstream Tracked upstream or vendor behavior labels Jun 3, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested priority: P2 (includes non-doc, non-test paths outside the low-risk bucket).

P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.

@Astro-Han
Astro-Han merged commit 88760be into dev Jun 3, 2026
35 of 36 checks passed
@Astro-Han
Astro-Han deleted the claude/i936-silent-200 branch June 3, 2026 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working harness Model harness, prompts, tool descriptions, and session mechanics P2 Medium priority upstream Tracked upstream or vendor behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant