From a5d4acc7b480b90f59a1397429e7b85dc835913c Mon Sep 17 00:00:00 2001 From: Joe Kralicky Date: Tue, 5 Nov 2024 15:44:41 -0500 Subject: [PATCH] config: only validate redirect response code when non-nil --- config/policy.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/config/policy.go b/config/policy.go index c82eceacc..f8172804e 100644 --- a/config/policy.go +++ b/config/policy.go @@ -233,12 +233,10 @@ func (r *PolicyRedirect) validate() error { // GetEnvoyResponseCode returns the ResponseCode as the corresponding Envoy enum value. func (r *PolicyRedirect) GetEnvoyResponseCode() (envoy_config_route_v3.RedirectAction_RedirectResponseCode, error) { - var code int32 - if r != nil && r.ResponseCode != nil { - code = *r.ResponseCode + if r == nil || r.ResponseCode == nil { + return envoy_config_route_v3.RedirectAction_RedirectResponseCode(0), nil } - - switch code { + switch code := *r.ResponseCode; code { case http.StatusMovedPermanently: return envoy_config_route_v3.RedirectAction_MOVED_PERMANENTLY, nil case http.StatusFound: