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 }