From 07fcbed400fad5113c3d2140b337bb657a88e091 Mon Sep 17 00:00:00 2001 From: Lukasz Dziedziak Date: Mon, 13 Nov 2023 06:07:58 +0100 Subject: [PATCH] feat(kuma-cp): map BadRequest error to 400 (#8312) Signed-off-by: Lukasz Dziedziak --- pkg/core/rest/errors/error_handler.go | 2 +- pkg/core/rest/errors/errors.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/core/rest/errors/error_handler.go b/pkg/core/rest/errors/error_handler.go index 95a4cb5f55e7..435c92c57310 100644 --- a/pkg/core/rest/errors/error_handler.go +++ b/pkg/core/rest/errors/error_handler.go @@ -33,7 +33,7 @@ func HandleError(ctx context.Context, response *restful.Response, err error, tit Title: title, Detail: "Not found", } - case errors.Is(err, &rest.InvalidResourceError{}) || errors.Is(err, ®istry.InvalidResourceTypeError{}) || errors.Is(err, &store.PreconditionError{}): + case errors.Is(err, &rest.InvalidResourceError{}), errors.Is(err, ®istry.InvalidResourceTypeError{}), errors.Is(err, &store.PreconditionError{}), errors.Is(err, &BadRequest{}): kumaErr = &types.Error{ Status: 400, Title: "Bad Request", diff --git a/pkg/core/rest/errors/errors.go b/pkg/core/rest/errors/errors.go index e341735ed309..085807a383c2 100644 --- a/pkg/core/rest/errors/errors.go +++ b/pkg/core/rest/errors/errors.go @@ -38,7 +38,7 @@ func NewBadRequestError(msg string) error { } func (e *BadRequest) Error() string { - if e.msg != "" { + if e.msg == "" { return "bad request" } return fmt.Sprintf("bad request: %s", e.msg)