[Logs UI] Handle undefined composite key in category dataset response (#90472)

This fixes the handling of Elasticsearch responses that don't contain a composite key when querying for the available category datasets.
This commit is contained in:
Felix Stürmer 2021-02-10 17:13:05 +01:00 committed by GitHub
parent 0fc9467e51
commit 874960e1c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -79,7 +79,7 @@ export async function getLatestLogEntriesCategoriesDatasetsStats(
return {
categorization_status: latestHitSource.categorization_status,
categorized_doc_count: latestHitSource.categorized_doc_count,
dataset: bucket.key.dataset ?? '',
dataset: bucket.key?.dataset ?? '',
dead_category_count: latestHitSource.dead_category_count,
failed_category_count: latestHitSource.failed_category_count,
frequent_category_count: latestHitSource.frequent_category_count,

View file

@ -98,9 +98,12 @@ export const logEntryCategorizerStatsHitRT = rt.type({
export type LogEntryCategorizerStatsHit = rt.TypeOf<typeof logEntryCategorizerStatsHitRT>;
const compositeDatasetKeyRT = rt.type({
dataset: rt.union([rt.string, rt.null]),
});
const compositeDatasetKeyRT = rt.union([
rt.type({
dataset: rt.union([rt.string, rt.null]),
}),
rt.undefined,
]);
export type CompositeDatasetKey = rt.TypeOf<typeof compositeDatasetKeyRT>;