From 792dcc4ac3c74ab0ebbd0f16792425e8232e6455 Mon Sep 17 00:00:00 2001 From: He Weiwei Date: Thu, 17 Dec 2020 16:58:49 +0800 Subject: [PATCH] fix(scan): returns 400 when artifact not support by scanner (#13785) Signed-off-by: He Weiwei --- api/v2.0/swagger.yaml | 2 ++ src/controller/scan/base_controller.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/v2.0/swagger.yaml b/api/v2.0/swagger.yaml index eada98c57..06b448841 100644 --- a/api/v2.0/swagger.yaml +++ b/api/v2.0/swagger.yaml @@ -548,6 +548,8 @@ paths: responses: '202': $ref: '#/responses/202' + '400': + $ref: '#/responses/400' '401': $ref: '#/responses/401' '403': diff --git a/src/controller/scan/base_controller.go b/src/controller/scan/base_controller.go index 6abe06d15..1d0142e54 100644 --- a/src/controller/scan/base_controller.go +++ b/src/controller/scan/base_controller.go @@ -192,7 +192,7 @@ func (bc *basicController) Scan(ctx context.Context, artifact *ar.Artifact, opti } if !scannable { - return errors.Errorf("the configured scanner %s does not support scanning artifact with mime type %s", r.Name, artifact.ManifestMediaType) + return errors.BadRequestError(nil).WithMessage("the configured scanner %s does not support scanning artifact with mime type %s", r.Name, artifact.ManifestMediaType) } type Param struct {