Skip to content

fix: propagate HTTP status from persistence.get through DocRoom.fetch response#134

Merged
kptdobe merged 1 commit intomainfrom
fix/propagate-auth-error-status
Apr 30, 2026
Merged

fix: propagate HTTP status from persistence.get through DocRoom.fetch response#134
kptdobe merged 1 commit intomainfrom
fix/propagate-auth-error-status

Conversation

@kptdobe
Copy link
Copy Markdown
Contributor

@kptdobe kptdobe commented Apr 30, 2026

Summary

  • persistence.get() now attaches err.status = initialReq.status to thrown errors so callers can read the original HTTP status code
  • DocRoom.fetch catch block reads err.status ?? 500 — 401/403/404 errors are now returned with their real status code; unknown errors still return 500 with "Internal Server Error"
  • For non-500 responses, the error message is used as the body to give clients actionable context

Background

When da-admin returns 401 or 403 (auth failure), the WebSocket upgrade path in DocRoom.fetch was catching those errors and always returning 500 "Internal Server Error". This made it impossible for clients and monitoring to distinguish auth failures from actual server bugs.

Observed in production logs: 401/403 auth errors showing up as 500 responses, making them look like worker crashes rather than expected auth rejections.

Test plan

  • All 86 tests pass (npm test)
  • Test persistence get 404 — verifies error carries status: 404
  • Test persistence get throws — verifies error carries status: 500
  • Test persistence get 401 carries status for propagation — new test for 401
  • Test persistence get 403 carries status for propagation — new test for 403
  • Test DocRoom fetch fails when document deleted after auth — updated: now expects 404
  • Test DocRoom fetch propagates 401 when auth check fails — new test
  • Test DocRoom fetch returns 500 for unexpected errors — new test verifying untyped errors still produce 500

🤖 Generated with Claude Code

… response

When da-admin returns 401/403/404, the error thrown by persistence.get now
carries an err.status property. DocRoom.fetch reads err.status ?? 500 so the
client receives the real status code instead of always getting 500.

This lets clients (and monitoring) distinguish auth failures from actual
server errors and enables correct retry / redirect behaviour on the client side.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kptdobe kptdobe requested a review from bosschaert April 30, 2026 13:18
@kptdobe kptdobe merged commit eac219d into main Apr 30, 2026
7 of 8 checks passed
@kptdobe kptdobe deleted the fix/propagate-auth-error-status branch April 30, 2026 14:26
adobe-bot pushed a commit that referenced this pull request Apr 30, 2026
## [1.2.1](v1.2.0...v1.2.1) (2026-04-30)

### Bug Fixes

* propagate HTTP status from persistence.get through DocRoom.fetch response ([#134](#134)) ([eac219d](eac219d))
@adobe-bot
Copy link
Copy Markdown

🎉 This PR is included in version 1.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants