Skip to content

Commit

Permalink
fix: improve session error logging (supabase#1655)
Browse files Browse the repository at this point in the history
## What kind of change does this PR introduce?
* Improve logging for missing session
* Helps provide better visibility for missing session errors encountered
in https://github.com/orgs/supabase/discussions/23715

## What is the current behavior?

Please link any relevant issues here.

## What is the new behavior?

Feel free to include screenshots if it includes visual changes.

## Additional context

Add any other context or screenshots.
  • Loading branch information
kangmingtay authored and LashaJini committed Nov 13, 2024
1 parent 245b929 commit 7eea05c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/api/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (a *API) maybeLoadUserOrSession(ctx context.Context) (context.Context, erro
session, err = models.FindSessionByID(db, sessionId, false)
if err != nil {
if models.IsNotFoundError(err) {
return ctx, forbiddenError(ErrorCodeSessionNotFound, "Session from session_id claim in JWT does not exist")
return ctx, forbiddenError(ErrorCodeSessionNotFound, "Session from session_id claim in JWT does not exist").WithInternalError(err).WithInternalMessage(fmt.Sprintf("session id (%s) doesn't exist", sessionId))
}
return ctx, err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/api/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (ts *AuthTestSuite) TestMaybeLoadUserOrSession() {
Role: "authenticated",
SessionId: "73bf9ee0-9e8c-453b-b484-09cb93e2f341",
},
ExpectedError: forbiddenError(ErrorCodeSessionNotFound, "Session from session_id claim in JWT does not exist"),
ExpectedError: forbiddenError(ErrorCodeSessionNotFound, "Session from session_id claim in JWT does not exist").WithInternalError(models.SessionNotFoundError{}).WithInternalMessage("session id (73bf9ee0-9e8c-453b-b484-09cb93e2f341) doesn't exist"),
ExpectedUser: u,
ExpectedSession: nil,
},
Expand Down

0 comments on commit 7eea05c

Please sign in to comment.