Skip to content

Commit 1d81638

Browse files
boehlkeclaude
andcommitted
refactor: use ClientError path for logout errors in handleError
Remove manual JSON formatting for logout errors and let them fall through to the existing ClientError branch, keeping a single point of JSON formatting. Remove redundant Reason() method from logoutError. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4743873 commit 1d81638

File tree

2 files changed

+1
-10
lines changed

2 files changed

+1
-10
lines changed

internal/http/error.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,3 @@ func (e logoutError) Error() string {
2525
func (e logoutError) Type() string {
2626
return "logout"
2727
}
28-
29-
// Reason returns the reason identifier for the client to handle logout redirection.
30-
func (e logoutError) Reason() string {
31-
return "Logout"
32-
}

internal/http/http.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,11 +537,7 @@ func handleError(ctx context.Context, w http.ResponseWriter, err error, writeSta
537537
if ctx != nil && oserror.ContextDone(err) {
538538
if cause := context.Cause(ctx); cause != nil {
539539
if _, isLogout := cause.(auth.LogoutError); isLogout {
540-
// Send logout error message so client can redirect to login
541-
logoutErr := logoutError{}
542-
fmt.Fprintf(w, `{"error": {"type": "%s", "msg": "%s", "reason": "%s"}}`, logoutErr.Type(), quote(logoutErr.Error()), logoutErr.Reason())
543-
fmt.Fprintln(w)
544-
return
540+
err = logoutError{}
545541
}
546542
}
547543
}

0 commit comments

Comments
 (0)