From fcc9b05d293d4a6af2d2da467e665baf56b7197b Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 21 Feb 2025 13:54:29 +0100 Subject: [PATCH] fix: return http 204 on test notification (#16651) This PR changes the API response for `/api/v2/notifications/test` endpoint to HTTP 204 / No Content. --- coderd/notifications.go | 2 +- codersdk/notifications.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/coderd/notifications.go b/coderd/notifications.go index 97cab982bd..812d8cd3e4 100644 --- a/coderd/notifications.go +++ b/coderd/notifications.go @@ -210,7 +210,7 @@ func (api *API) postTestNotification(rw http.ResponseWriter, r *http.Request) { return } - httpapi.Write(ctx, rw, http.StatusOK, nil) + rw.WriteHeader(http.StatusNoContent) } // @Summary Get user notification preferences diff --git a/codersdk/notifications.go b/codersdk/notifications.go index 560499a672..ac5fe8e60b 100644 --- a/codersdk/notifications.go +++ b/codersdk/notifications.go @@ -200,10 +200,9 @@ func (c *Client) PostTestNotification(ctx context.Context) error { } defer res.Body.Close() - if res.StatusCode != http.StatusOK { + if res.StatusCode != http.StatusNoContent { return ReadBodyAsError(res) } - return nil }