From da755ea2eae24d761948ac50002c45aa44c46761 Mon Sep 17 00:00:00 2001 From: Sharon Katz <121527325+sharon-fdm@users.noreply.github.com> Date: Mon, 11 Dec 2023 12:34:59 -0500 Subject: [PATCH] Bug-15430 change timeout errror code to 408 (#15552) --- changes/15430-change-script-timeout-error-code-to-408 | 1 + server/service/scripts.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changes/15430-change-script-timeout-error-code-to-408 diff --git a/changes/15430-change-script-timeout-error-code-to-408 b/changes/15430-change-script-timeout-error-code-to-408 new file mode 100644 index 0000000000..87509228e8 --- /dev/null +++ b/changes/15430-change-script-timeout-error-code-to-408 @@ -0,0 +1 @@ +- POST /api/v1/fleet/scripts/run/sync timeout (longer than 60 seconds) will now return error code: 408 instead of 504 diff --git a/server/service/scripts.go b/server/service/scripts.go index e25e31c64a..0732f785c8 100644 --- a/server/service/scripts.go +++ b/server/service/scripts.go @@ -64,7 +64,11 @@ type runScriptSyncResponse struct { func (r runScriptSyncResponse) error() error { return r.Err } func (r runScriptSyncResponse) Status() int { if r.HostTimeout { - return http.StatusGatewayTimeout + // The more proper response for a timeout on the server would be: StatusGatewayTimeout = 504 + // However, as described in https://github.com/fleetdm/fleet/issues/15430 we will send: + // StatusRequestTimeout = 408 // RFC 9110, 15.5.9 + // See: https://github.com/fleetdm/fleet/issues/15430#issuecomment-1847345617 + return http.StatusRequestTimeout } return http.StatusOK }