Skip to content

Commit e9848af

Browse files
committed
fixing bug in DFA deletion
1 parent d6d57b8 commit e9848af

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

x-pack/plugins/ml/server/routes/data_frame_analytics.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -324,19 +324,20 @@ export function dataFrameAnalyticsRoutes({ router, mlLicense }: RouteInitializat
324324
success: false,
325325
};
326326

327-
// Check if analyticsId is valid and get destination index
328-
if (deleteDestIndex || deleteDestIndexPattern) {
329-
try {
330-
const { body } = await client.asInternalUser.ml.getDataFrameAnalytics({
331-
id: analyticsId,
332-
});
333-
if (Array.isArray(body.data_frame_analytics) && body.data_frame_analytics.length > 0) {
334-
destinationIndex = body.data_frame_analytics[0].dest.index;
335-
}
336-
} catch (e) {
337-
return response.customError(wrapError(e));
327+
try {
328+
// Check if analyticsId is valid and get destination index
329+
const { body } = await client.asInternalUser.ml.getDataFrameAnalytics({
330+
id: analyticsId,
331+
});
332+
if (Array.isArray(body.data_frame_analytics) && body.data_frame_analytics.length > 0) {
333+
destinationIndex = body.data_frame_analytics[0].dest.index;
338334
}
335+
} catch (e) {
336+
// exist early if the job doesn't exist
337+
return response.customError(wrapError(e));
338+
}
339339

340+
if (deleteDestIndex || deleteDestIndexPattern) {
340341
// If user checks box to delete the destinationIndex associated with the job
341342
if (destinationIndex && deleteDestIndex) {
342343
// Verify if user has privilege to delete the destination index

0 commit comments

Comments
 (0)