Skip to content

[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

Merged
merged 6 commits into from
Jul 9, 2025

Conversation

rbrtj
Copy link
Contributor

@rbrtj rbrtj commented Jul 4, 2025

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.

@rbrtj rbrtj self-assigned this Jul 4, 2025
@rbrtj rbrtj requested a review from a team as a code owner July 4, 2025 13:46
@rbrtj rbrtj added :ml release_note:skip Skip the PR/issue when compiling release notes Team:ML Team label for ML (also use :ml) v9.2.0 labels Jul 4, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@rbrtj rbrtj requested a review from darnautov July 4, 2025 13:47
@rbrtj rbrtj added the backport:skip This commit does not require backporting label Jul 4, 2025
…urce-definitions/scripts/fix-location-collection.ts'
@rbrtj rbrtj marked this pull request as draft July 4, 2025 15:18
@rbrtj rbrtj marked this pull request as ready for review July 7, 2025 08:20
Copy link
Contributor

@darnautov darnautov left a 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) {
Copy link
Contributor

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

Suggested change
if ((err as any)?.statusCode === 404) {
if (typeof err === 'object' && Object.hasOwn(err, 'statusCode') && err.statusCode === 404) {

Copy link
Contributor Author

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;
  }

5c7d41d

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

improved check in a6d469c

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @rbrtj

@rbrtj rbrtj merged commit 40bed5a into elastic:main Jul 9, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting :ml release_note:skip Skip the PR/issue when compiling release notes Team:ML Team label for ML (also use :ml) v9.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ML] Mark Anomaly Detection Rule Errors as User Errors
4 participants