From db94b30b1c418b3ab77a0f5e205a2992288b10e7 Mon Sep 17 00:00:00 2001 From: Stephen Kirby <58410745+stirby@users.noreply.github.com> Date: Wed, 7 Aug 2024 11:56:07 -0500 Subject: [PATCH] fix: patch known issues in 2.14.1 (#14207) * chore: revert status code change for delete users endpoint (#14168) Revert from https://github.com/coder/coder/pull/13870 (cherry picked from commit b80d99550a83d4d87175df333eb5075f69920984) * chore: delete user codersdk to support status code regression (#14173) * chore: delete user codersdk to support status code regression * Update codersdk/users.go Co-authored-by: Kayla Washburn-Love --------- Co-authored-by: Kayla Washburn-Love (cherry picked from commit b55a7a8b78eec065fbd8eb763916285c472cc3e0) * fix: add template editor to /templates/:templateName route group (#14206) (cherry picked from commit d0feb70811b0acc789e63911d6a47fc6433bf841) --------- Co-authored-by: Steven Masley Co-authored-by: Kayla Washburn-Love --- coderd/apidoc/docs.go | 4 ++-- coderd/apidoc/swagger.json | 4 ++-- coderd/users.go | 6 ++++-- codersdk/users.go | 4 +++- docs/api/users.md | 6 +++--- site/src/router.tsx | 4 ++++ 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index 981be686df469..28ccc0630d7b7 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -4845,8 +4845,8 @@ const docTemplate = `{ } ], "responses": { - "204": { - "description": "No Content" + "200": { + "description": "OK" } } } diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 14efc71711687..2008e23744db7 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -4273,8 +4273,8 @@ } ], "responses": { - "204": { - "description": "No Content" + "200": { + "description": "OK" } } } diff --git a/coderd/users.go b/coderd/users.go index adf329ea0059d..cde7271ca4e5d 100644 --- a/coderd/users.go +++ b/coderd/users.go @@ -513,7 +513,7 @@ func (api *API) postUser(rw http.ResponseWriter, r *http.Request) { // @Security CoderSessionToken // @Tags Users // @Param user path string true "User ID, name, or me" -// @Success 204 +// @Success 200 // @Router /users/{user} [delete] func (api *API) deleteUser(rw http.ResponseWriter, r *http.Request) { ctx := r.Context() @@ -588,7 +588,9 @@ func (api *API) deleteUser(rw http.ResponseWriter, r *http.Request) { } } - rw.WriteHeader(http.StatusNoContent) + httpapi.Write(ctx, rw, http.StatusOK, codersdk.Response{ + Message: "User has been deleted!", + }) } // Returns the parameterized user requested. All validation diff --git a/codersdk/users.go b/codersdk/users.go index 391363309f577..a715194c11978 100644 --- a/codersdk/users.go +++ b/codersdk/users.go @@ -309,7 +309,9 @@ func (c *Client) DeleteUser(ctx context.Context, id uuid.UUID) error { return err } defer res.Body.Close() - if res.StatusCode != http.StatusNoContent { + // Check for a 200 or a 204 response. 2.14.0 accidentally included a 204 response, + // which was a breaking change, and reverted in 2.14.1. + if res.StatusCode != http.StatusOK && res.StatusCode != http.StatusNoContent { return ReadBodyAsError(res) } return nil diff --git a/docs/api/users.md b/docs/api/users.md index 5b521183fcd23..05af30df869e0 100644 --- a/docs/api/users.md +++ b/docs/api/users.md @@ -426,9 +426,9 @@ curl -X DELETE http://coder-server:8080/api/v2/users/{user} \ ### Responses -| Status | Meaning | Description | Schema | -| ------ | --------------------------------------------------------------- | ----------- | ------ | -| 204 | [No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5) | No Content | | +| Status | Meaning | Description | Schema | +| ------ | ------------------------------------------------------- | ----------- | ------ | +| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | | To perform this operation, you must be authenticated. [Learn more](authentication.md). diff --git a/site/src/router.tsx b/site/src/router.tsx index 615d12969e184..634625b1fb8a2 100644 --- a/site/src/router.tsx +++ b/site/src/router.tsx @@ -472,6 +472,10 @@ export const router = createBrowserRouter( {/* Pages that don't have the dashboard layout */} } /> + } + /> }