Prevent exception when panel has multiple queries (#49368) (#49562)

This fixes the issues that when a panel has multiple queries this throws an exception if source is not part of the current frame

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
(cherry picked from commit eab806620c)

Co-authored-by: Ward Bekker <ward@wardbekker.com>
This commit is contained in:
Grot (@grafanabot)
2022-05-25 10:05:02 +02:00
committed by GitHub
co-authored by Ward Bekker
parent b5da0dcf39
commit 49e653dbaf
@@ -41,7 +41,8 @@ function addExtractedFields(frame: DataFrame, options: ExtractFieldsOptions): Da
}
const source = findField(frame, options.source);
if (!source) {
throw new Error('json field not found');
// this case can happen when there are multiple queries
return frame;
}
const ext = fieldExtractors.getIfExists(options.format ?? FieldExtractorID.Auto);