Skip to content

[ML] Remove unsupported project_routing from clear job audit messages - #288210

Merged
wildemat merged 2 commits into
elastic:mainfrom
wildemat:fix/ml-cps-clear-job-audit-messages-project-routing
Sep 1, 2026
Merged

[ML] Remove unsupported project_routing from clear job audit messages#288210
wildemat merged 2 commits into
elastic:mainfrom
wildemat:fix/ml-cps-clear-job-audit-messages-project-routing

Conversation

@wildemat

@wildemat wildemat commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Clearing ML anomaly detection job notifications fails with an HTTP 400 on serverless projects with CPS enabled:

parsing_exception: Unknown key for a VALUE_STRING in [project_routing]

clearJobAuditMessages passed project_routing into asInternalUser.updateByQuery(...) and asInternalUser.index(...). Neither Elasticsearch API accepts that parameter, and the ES client just forwarded the unrecognized params.

  • update_by_query: 400 when this function sends project_routing to ES query body
  • index: project_routing was just written into the _source of the index's documents for this case. So index documents up until now that have hit this issue don't need to be cleaned up.

The three search calls in the same file keep their project_routing, because they declare project_routing in acceptedParams

Core's CPS request handler already injects project_routing automatically for APIs that accept it (acceptedParams). Removing these manual spreads won't regress anything.

Type issue

Typecheck didn't catch it because conditional spread operator doesn't trip excess property check.

UpdateByQueryRequest and IndexRequest do not declare project_routing; SearchRequest, FieldCapsRequest and MsearchRequest do.

Testing

New job_audit_messages.test.ts with three cases:

  1. updateByQuery receives no project_routing.
  2. index receives no project_routing, on params or the document body.
  3. search still receives project_routing

Two new tests failed on latest main changes and passed after these changes.

Closes https://github.com/elastic/sdh-kibana/issues/6491
Regression introduced by #251270

Checklist

  • Unit or functional tests were updated or added to match the most common scenarios
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.

Not applicable: no user-facing text (no i18n), no documentation changes, no plugin configuration keys, no HTTP API changes, no existing tests changed (only new tests added, so no Flaky Test Runner run).

Identify risks

Low risk. This removes a parameter that the two affected Elasticsearch APIs never accepted, and which Core injects automatically where it is accepted.

Made with Cursor, further reviewed and edited by @wildemat

The update_by_query and index APIs do not accept project_routing. The ES
client forwards unrecognised parameters into the request body, so passing it
made update_by_query fail with a parsing_exception and silently added a stray
field to the indexed notification document.

Closes elastic/sdh-kibana#6491

Co-authored-by: Cursor <cursoragent@cursor.com>
@wildemat
wildemat requested a review from a team as a code owner August 31, 2026 20:53
@wildemat
wildemat requested a review from jgowdyelastic August 31, 2026 20:53
@wildemat wildemat added :ml backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes labels Aug 31, 2026
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

Pinging @elastic/ml-ui (:ml)

Co-authored-by: Cursor <cursoragent@cursor.com>
@kibanamachine

Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

Test Failures

  • [job] [logs] Scout Lane #15 - stateful-classic / default / local-stateful-classic - Dataset quality - data stream stats across data stream types - returns the stats of every requested data stream type
  • [job] [logs] FTR Configs #78 / visualize app annotation listing page edit data view switching recovers from missing field in data view

@jgowdyelastic jgowdyelastic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@wildemat
wildemat merged commit 73b8a61 into elastic:main Sep 1, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting :ml release_note:skip Skip the PR/issue when compiling release notes v9.6.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants