Skip to content

fix: GET /me auth guard now respects formatErrorResponse - #7

Merged
ahmadhuss merged 1 commit into
mainfrom
fix/me-route-envelope
Jul 25, 2026
Merged

fix: GET /me auth guard now respects formatErrorResponse#7
ahmadhuss merged 1 commit into
mainfrom
fix/me-route-envelope

Conversation

@ahmadhuss

Copy link
Copy Markdown
Member

Summary

GET /me was the one route in the router still using the standalone authMiddleware() helper as route middleware, which hardcodes a { success, message } error body regardless of a consumer's formatErrorResponse override. Every other route (and the router's own catch-all error handler) already went through the configurable respondError. Fixed by inlining the same cookie/bearer token check directly into the /me handler.

Found while integration-testing a real consumer with a custom envelope: its other protected routes got the custom shape correctly, but /me's own 401 slipped through with the default shape.

Test plan

  • Added a regression test asserting a missing/invalid token on /me returns the custom formatErrorResponse shape
  • bun run build — clean
  • bun run test — 43/43 pass (33 core incl. the new test, 16 sqlite)
  • bun run typecheck / bun run lint — clean
  • Patch changeset added

/me was the only route still using the standalone authMiddleware() helper
as route middleware, which hardcodes { success, message } regardless of a
consumer's formatErrorResponse override. Inlined the same token/cookie
check the handler already had access to, so a missing or invalid token on
/me gets the same configured envelope as every other error in the router.

Caught while integrating a real consumer with a custom envelope - its
protected non-auth routes got the custom shape correctly, but /me's own
401 did not.
@ahmadhuss
ahmadhuss merged commit 4758365 into main Jul 25, 2026
1 check passed
@ahmadhuss
ahmadhuss deleted the fix/me-route-envelope branch July 25, 2026 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant