Skip to content

Commit

Permalink
fix bug where convertToSnakeCase would throw error 'cannot convert nu…
Browse files Browse the repository at this point in the history
…ll or undefined to object' if passed null
  • Loading branch information
dhurley14 committed Jan 17, 2020
1 parent 6fb3b35 commit 6a91090
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ export const createFindRulesStatusRoute: Hapi.ServerRoute = {
return {
...(await acc),
[id]: {
current_status: convertToSnakeCase(lastFiveErrorsForId.saved_objects[0].attributes),
current_status:
lastFiveErrorsForId.saved_objects.length > 0
? convertToSnakeCase(lastFiveErrorsForId.saved_objects[0].attributes)
: null,
failures: lastFiveErrorsForId.saved_objects
.slice(1)
.map(errorItem => convertToSnakeCase(errorItem.attributes)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export interface IRuleStatusAttributes {

export interface RuleStatusResponse {
[key: string]: {
current_status: IRuleStatusAttributes;
failures: IRuleStatusAttributes[];
current_status: IRuleStatusAttributes | null | undefined;
failures: IRuleStatusAttributes[] | null | undefined;
};
}

Expand Down

0 comments on commit 6a91090

Please sign in to comment.