Skip to content

Commit

Permalink
fixing bug in DFA deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Sep 9, 2020
1 parent d6d57b8 commit e9848af
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions x-pack/plugins/ml/server/routes/data_frame_analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,19 +324,20 @@ export function dataFrameAnalyticsRoutes({ router, mlLicense }: RouteInitializat
success: false,
};

// Check if analyticsId is valid and get destination index
if (deleteDestIndex || deleteDestIndexPattern) {
try {
const { body } = await client.asInternalUser.ml.getDataFrameAnalytics({
id: analyticsId,
});
if (Array.isArray(body.data_frame_analytics) && body.data_frame_analytics.length > 0) {
destinationIndex = body.data_frame_analytics[0].dest.index;
}
} catch (e) {
return response.customError(wrapError(e));
try {
// Check if analyticsId is valid and get destination index
const { body } = await client.asInternalUser.ml.getDataFrameAnalytics({
id: analyticsId,
});
if (Array.isArray(body.data_frame_analytics) && body.data_frame_analytics.length > 0) {
destinationIndex = body.data_frame_analytics[0].dest.index;
}
} catch (e) {
// exist early if the job doesn't exist
return response.customError(wrapError(e));
}

if (deleteDestIndex || deleteDestIndexPattern) {
// If user checks box to delete the destinationIndex associated with the job
if (destinationIndex && deleteDestIndex) {
// Verify if user has privilege to delete the destination index
Expand Down

0 comments on commit e9848af

Please sign in to comment.