Home

boring / v2

publicBoring-Software-Inc/v2
Overview Code History Branches Pull requestsIssuesInsights Campfire Docs
main
HomeOverview Code PRsIssues

fix(web): throw notFound()/redirect() from server guards, not raw Response

3 months ago

7d4d3cd
Authored
grim7/24/2026, 7:58:54 AM
A raw `throw new Response(...)` in the org/staff/session guards can't cross the
server-fn RPC boundary — Seroval can't serialize a Response, so SSR route loads
crashed (opening a non-member/nonexistent org 404'd with a client "Invariant
failed" + server "Seroval Error" instead of a clean not-found). Guards now throw
TanStack control-flow that serializes cleanly:

- org-guard: every denial — no session, no such org, non-member, or
  member-but-not-admin — collapses to notFound(), so org existence is never
  disclosed (same posture as /admin).
- staff-guard: 404 denials -> notFound().
- session gate: no session -> redirect('/login').
- moderation-queue: foreign/missing item -> notFound().

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Parent6566405

5 files changed
  • apps/web/src/lib/moderation-queue.functions.ts+2−1
  • apps/web/src/lib/server/org-guard.ts+17−12
  • apps/web/src/lib/server/session.test.ts+10−5
  • apps/web/src/lib/server/session.ts+7−3
  • apps/web/src/lib/server/staff-guard.ts+3−2