fix: return BAD_REQUEST when validate project metadata public value error

Signed-off-by: chlins <chenyuzh@vmware.com>
This commit is contained in:
chlins 2022-03-29 14:57:17 +08:00
parent 1449988353
commit 4af3725cc2

View File

@ -150,7 +150,7 @@ func (a *projectAPI) CreateProject(ctx context.Context, params operation.CreateP
// validate metadata.public value, should only be "true" or "false"
if p := req.Metadata.Public; p != "" {
if p != "true" && p != "false" {
return a.SendError(ctx, errors.Errorf("metadata.public should only be 'true' or 'false', but got: '%s'", p))
return a.SendError(ctx, errors.BadRequestError(nil).WithMessage(fmt.Sprintf("metadata.public should only be 'true' or 'false', but got: '%s'", p)))
}
}