diff --git a/packages/api/src/elastic/labels.ts b/packages/api/src/elastic/labels.ts index 4a77cc9f1..25f479704 100644 --- a/packages/api/src/elastic/labels.ts +++ b/packages/api/src/elastic/labels.ts @@ -104,7 +104,7 @@ export const deleteLabel = async ( index: INDEX_ALIAS, body: { script: { - source: `if (ctx._source.highlights != null) { + source: `if (ctx._source.highlights != null && ctx._source.highlights[0].labels != null) { ctx._source.highlights[0].labels.removeIf(label -> label.name == params.label) } if (ctx._source.labels != null) {