Skip to content

Commit

Permalink
[Security Solution] put back savedObjectId in error message (#74775) (#…
Browse files Browse the repository at this point in the history
…74866)

* put back savedObjectId in error message

* fix type error
  • Loading branch information
angorayc authored Aug 12, 2020
1 parent 4368f63 commit be34b0f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import React, { useCallback, useState } from 'react';
import {
ImportDataResponse,
ImportDataProps,
ImportRulesResponseError,
ImportResponseError,
} from '../../../detections/containers/detection_engine/rules';
import {
displayErrorToast,
Expand All @@ -49,6 +51,12 @@ interface ImportDataModalProps {
title: string;
}

const isImportRulesResponseError = (
error: ImportRulesResponseError | ImportResponseError
): error is ImportRulesResponseError => {
return (error as ImportRulesResponseError).rule_id !== undefined;
};

/**
* Modal component for importing Rules from a json file
*/
Expand Down Expand Up @@ -97,7 +105,11 @@ export const ImportDataModalComponent = ({
}
if (importResponse.errors.length > 0) {
const formattedErrors = importResponse.errors.map((e) =>
failedDetailed(e.rule_id, e.error.status_code, e.error.message)
failedDetailed(
isImportRulesResponseError(e) ? e.rule_id : e.id,
e.error.status_code,
e.error.message
)
);
displayErrorToast(errorMessage, formattedErrors, dispatchToaster);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,18 @@ export interface ImportRulesResponseError {
};
}

export interface ImportResponseError {
id: string;
error: {
status_code: number;
message: string;
};
}

export interface ImportDataResponse {
success: boolean;
success_count: number;
errors: ImportRulesResponseError[];
errors: Array<ImportRulesResponseError | ImportResponseError>;
}

export interface ExportDocumentsProps {
Expand Down

0 comments on commit be34b0f

Please sign in to comment.