Skip to content

Commit be7e21c

Browse files
authored
[Security Solution] put back savedObjectId in error message (#74775)
* put back savedObjectId in error message * fix type error
1 parent 64b609b commit be7e21c

File tree

2 files changed

+22
-2
lines changed
  • x-pack/plugins/security_solution/public
    • common/components/import_data_modal
    • detections/containers/detection_engine/rules

2 files changed

+22
-2
lines changed

x-pack/plugins/security_solution/public/common/components/import_data_modal/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import React, { useCallback, useState } from 'react';
2323
import {
2424
ImportDataResponse,
2525
ImportDataProps,
26+
ImportRulesResponseError,
27+
ImportResponseError,
2628
} from '../../../detections/containers/detection_engine/rules';
2729
import {
2830
displayErrorToast,
@@ -48,6 +50,12 @@ interface ImportDataModalProps {
4850
title: string;
4951
}
5052

53+
const isImportRulesResponseError = (
54+
error: ImportRulesResponseError | ImportResponseError
55+
): error is ImportRulesResponseError => {
56+
return (error as ImportRulesResponseError).rule_id !== undefined;
57+
};
58+
5159
/**
5260
* Modal component for importing Rules from a json file
5361
*/
@@ -96,7 +104,11 @@ export const ImportDataModalComponent = ({
96104
}
97105
if (importResponse.errors.length > 0) {
98106
const formattedErrors = importResponse.errors.map((e) =>
99-
failedDetailed(e.rule_id, e.error.status_code, e.error.message)
107+
failedDetailed(
108+
isImportRulesResponseError(e) ? e.rule_id : e.id,
109+
e.error.status_code,
110+
e.error.message
111+
)
100112
);
101113
displayErrorToast(errorMessage, formattedErrors, dispatchToaster);
102114
}

x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/types.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,18 @@ export interface ImportRulesResponseError {
234234
};
235235
}
236236

237+
export interface ImportResponseError {
238+
id: string;
239+
error: {
240+
status_code: number;
241+
message: string;
242+
};
243+
}
244+
237245
export interface ImportDataResponse {
238246
success: boolean;
239247
success_count: number;
240-
errors: ImportRulesResponseError[];
248+
errors: Array<ImportRulesResponseError | ImportResponseError>;
241249
}
242250

243251
export interface ExportDocumentsProps {

0 commit comments

Comments
 (0)