From: Gusted Date: Sun, 16 Oct 2022 16:56:58 +0000 (+0000) Subject: Return 404 when user is not found on avatar (#21476) (#21477) X-Git-Tag: v1.17.4~53 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3f032759ed40c8815e301cf5cc9f64f04864f731;p=gitea.git Return 404 when user is not found on avatar (#21476) (#21477) - Backport #21476 - Instead of returning a 500 Internal Server when the user wasn't found, return 404 Not found. --- diff --git a/routers/web/user/avatar.go b/routers/web/user/avatar.go index 53a603fab0..05896299d2 100644 --- a/routers/web/user/avatar.go +++ b/routers/web/user/avatar.go @@ -31,6 +31,10 @@ func AvatarByUserName(ctx *context.Context) { if strings.ToLower(userName) != "ghost" { var err error if user, err = user_model.GetUserByName(ctx, userName); err != nil { + if user_model.IsErrUserNotExist(err) { + ctx.NotFound("GetUserByName", err) + return + } ctx.ServerError("Invalid user: "+userName, err) return }