Skip to content

Commit

Permalink
fix: 粘贴从其他业务复制的标签,导致公共脚本列表页面报错 TencentBlueKing#2183
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliaozhong committed Sep 5, 2023
1 parent 9ad6663 commit f3436c6
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -176,6 +177,11 @@ public List<TagDTO> createNewTagIfNotExist(List<TagDTO> 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());
}
}
Expand Down Expand Up @@ -227,11 +233,14 @@ public List<ResourceTagDTO> listResourceTagsByTagIds(Long appId, List<Long> tagI
}

private void checkTags(Long appId, List<TagDTO> tags) {
tags.forEach(tag -> {
Iterator<TagDTO> 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
Expand Down

0 comments on commit f3436c6

Please sign in to comment.