-
Notifications
You must be signed in to change notification settings - Fork 8.4k
[ML] Anomaly Detection Alerting: Mark User Errors #226586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Anomaly Detection Alerting: Mark User Errors #226586
Conversation
Pinging @elastic/ml-ui (:ml) |
…urce-definitions/scripts/fix-location-collection.ts'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall, left 1 suggestion
return true; | ||
} | ||
|
||
if ((err as any)?.statusCode === 404) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's avoid using any
, something like this should work
if ((err as any)?.statusCode === 404) { | |
if (typeof err === 'object' && Object.hasOwn(err, 'statusCode') && err.statusCode === 404) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object.hasOwn(..)
doesn't provide type narrowing, so err.statusCode
causes an error in your example.
I came up with smth like this:
if (err !== null && typeof err === 'object' && 'statusCode' in err && err.statusCode === 404) {
return true;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'statusCode' in err
is also true if statusCode
exist in the prototype chain. the important part in you need to add it err !== null
, the rest could remain the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improved check in a6d469c
💚 Build Succeeded
Metrics [docs]
History
cc @rbrtj |
Resolves #212332
This PR marks errors such as
No jobs found..
,No datafeed found
as user errors to prevent them from affecting SLOs and alerts.However, there are additional errors that require further investigation, which will be addressed in a follow-up.