Skip to content

Commit 6a91090

Browse files
committed
fix bug where convertToSnakeCase would throw error 'cannot convert null or undefined to object' if passed null
1 parent 6fb3b35 commit 6a91090

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_status_route.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ export const createFindRulesStatusRoute: Hapi.ServerRoute = {
6868
return {
6969
...(await acc),
7070
[id]: {
71-
current_status: convertToSnakeCase(lastFiveErrorsForId.saved_objects[0].attributes),
71+
current_status:
72+
lastFiveErrorsForId.saved_objects.length > 0
73+
? convertToSnakeCase(lastFiveErrorsForId.saved_objects[0].attributes)
74+
: null,
7275
failures: lastFiveErrorsForId.saved_objects
7376
.slice(1)
7477
.map(errorItem => convertToSnakeCase(errorItem.attributes)),

x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ export interface IRuleStatusAttributes {
5858

5959
export interface RuleStatusResponse {
6060
[key: string]: {
61-
current_status: IRuleStatusAttributes;
62-
failures: IRuleStatusAttributes[];
61+
current_status: IRuleStatusAttributes | null | undefined;
62+
failures: IRuleStatusAttributes[] | null | undefined;
6363
};
6464
}
6565

0 commit comments

Comments
 (0)