From 896cb9ddceae6c02811a33e8a323b877cf100151 Mon Sep 17 00:00:00 2001 From: Victor Marin <36818606+mdvictor@users.noreply.github.com> Date: Fri, 9 Dec 2022 09:09:29 +0200 Subject: [PATCH] Fix index out of range in regenerateLinksSupplier (#60011) --- public/app/plugins/panel/timeseries/utils.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/public/app/plugins/panel/timeseries/utils.ts b/public/app/plugins/panel/timeseries/utils.ts index f8008bb0c27..316c765c633 100644 --- a/public/app/plugins/panel/timeseries/utils.ts +++ b/public/app/plugins/panel/timeseries/utils.ts @@ -142,20 +142,16 @@ export function regenerateLinksSupplier( timeZone: string ): DataFrame { alignedDataFrame.fields.forEach((field) => { - const frameIndex = field.state?.origin?.frameIndex; - - if (frameIndex === undefined) { + if (field.state?.origin?.frameIndex === undefined || frames[field.state?.origin?.frameIndex] === undefined) { return; } - const frame = frames[frameIndex]; - const tempFields: Field[] = []; - /* check if field has sortedVector values if it does, sort all string fields in the original frame by the order array already used for the field otherwise just attach the fields to the temporary frame used to get the links */ - for (const frameField of frame.fields) { + const tempFields: Field[] = []; + for (const frameField of frames[field.state?.origin?.frameIndex].fields) { if (frameField.type === FieldType.string) { if (field.values instanceof SortedVector) { const copiedField = { ...frameField };