From 0a75c52a8cb13af4d29599e7e1fbeb507565aab4 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 19 Aug 2022 14:36:58 +0800 Subject: [PATCH] Fix getting script_exception when updating labels in highlights by checking null before updating --- packages/api/src/elastic/labels.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api/src/elastic/labels.ts b/packages/api/src/elastic/labels.ts index 3c1423f7c..d5f931553 100644 --- a/packages/api/src/elastic/labels.ts +++ b/packages/api/src/elastic/labels.ts @@ -186,7 +186,7 @@ export const updateLabel = async ( ctx._source.labels.add(params.label); ctx._source.updatedAt = params.updatedAt } - if (ctx._source.highlights != null) { + if (ctx._source.highlights != null && ctx._source.highlights[0].labels != null) { ctx._source.highlights[0].labels.removeIf(l -> l.id == params.label.id); ctx._source.highlights[0].labels.add(params.label); ctx._source.updatedAt = params.updatedAt