Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Handle index not found error #273

Merged
merged 2 commits into from
Aug 11, 2020

Conversation

ohltyler
Copy link
Contributor

@ohltyler ohltyler commented Aug 5, 2020

Issue #, if available:

Description of changes:

#267 propagated a generic message to the user when there was errors retrieving detectors on the dashboard and detector list pages. One of these errors included an index_not_found_exception, which is most likely not an error, but is because the housekeeping AD indices are not all created until a user creates and starts a detector.

This fixes that by suppressing that error, similar to how the existing searchDetector() was doing it, and consequently doesn't show any errors on the dashboard and detector list pages when those indices don't exist yet.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

err.statusCode === 404 &&
get<string>(err, 'body.error.type', '') === 'index_not_found_exception'
) {
if (isIndexNotFoundError(err)) {
return { ok: true, response: { totalDetectors: 0, detectors: [] } };
}
console.log('Anomaly detector - Unable to search detectors', err);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would prefer logging before any return, right after catch. same below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would prefer logging before any return, right after catch. same below.

In this case, do you mean adding an additional log in the if block here? Could add

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. just moving console.log() before if(isIndexNotFoundError)should be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I see, will change

@ohltyler ohltyler merged commit 4895ba6 into opendistro-for-elasticsearch:master Aug 11, 2020
@ohltyler ohltyler deleted the removeError branch August 11, 2020 23:39
@ohltyler ohltyler added the enhancement Enhance current feature for better performance, user experience, etc label Aug 26, 2020
yizheliu-amazon pushed a commit that referenced this pull request Aug 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Enhance current feature for better performance, user experience, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unnecessary error on dashboard and detector list when no detectors created
3 participants