From f3436c6f56aa85684c1d5edab9728c9ad4dbddfc Mon Sep 17 00:00:00 2001 From: liuliaozhong Date: Tue, 5 Sep 2023 17:32:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=B2=98=E8=B4=B4=E4=BB=8E=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E4=B8=9A=E5=8A=A1=E5=A4=8D=E5=88=B6=E7=9A=84=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=EF=BC=8C=E5=AF=BC=E8=87=B4=E5=85=AC=E5=85=B1=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2=E6=8A=A5=E9=94=99?= =?UTF-8?q?=20#2183?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../job/manage/service/impl/TagServiceImpl.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/TagServiceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/TagServiceImpl.java index c4c8fd8b7c..fac6ba7b47 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/TagServiceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/TagServiceImpl.java @@ -29,6 +29,7 @@ import com.tencent.bk.job.common.exception.AlreadyExistsException; import com.tencent.bk.job.common.exception.InternalException; import com.tencent.bk.job.common.exception.InvalidParamException; +import com.tencent.bk.job.common.exception.NotFoundException; import com.tencent.bk.job.common.model.BaseSearchCondition; import com.tencent.bk.job.common.model.PageData; import com.tencent.bk.job.common.util.check.MaxLengthChecker; @@ -176,6 +177,11 @@ public List createNewTagIfNotExist(List tags, Long appId, String if (tagIdList.contains(tag.getId())) { tagIterator.remove(); } else { + TagDTO existTag = getTagInfoById(appId, tag.getId()); + if (existTag == null) { + throw new InvalidParamException(ErrorCode.ILLEGAL_PARAM_WITH_PARAM_NAME_AND_REASON, + new String[]{"tagId", String.format("tag (id=%s, app_id=%s) not exist", tag.getId(), appId)}); + } tagIdList.add(tag.getId()); } } @@ -227,11 +233,14 @@ public List listResourceTagsByTagIds(Long appId, List tagI } private void checkTags(Long appId, List tags) { - tags.forEach(tag -> { + Iterator iterator = tags.iterator(); + while (iterator.hasNext()) { + TagDTO tag = iterator.next(); if (!tag.getAppId().equals(appId) && !tag.getAppId().equals(JobConstants.PUBLIC_APP_ID)) { - throw new InternalException("Tag is not exist", ErrorCode.INTERNAL_ERROR); + log.warn(String.format("Tag is not exist, appId=%s, tagId=%s", appId, tag.getId())); + iterator.remove(); } - }); + } } @Override