Skip to content

[ML] Omit uncomputed model stats#146186

Merged
prwhelan merged 7 commits intoelastic:mainfrom
prwhelan:2112
Apr 15, 2026
Merged

[ML] Omit uncomputed model stats#146186
prwhelan merged 7 commits intoelastic:mainfrom
prwhelan:2112

Conversation

@prwhelan
Copy link
Copy Markdown
Member

There is a chance that a model does not have its stats computed when usage is called, potentially throwing a NullPointerException. Usage will now skip models that do not have stats yet.

There is a chance that a model does not have its stats computed when
usage is called, potentially throwing a NullPointerException. Usage will
now skip models that do not have stats yet.
@prwhelan prwhelan marked this pull request as ready for review April 14, 2026 15:14
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/ml-core (Team:ML)

@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Hi @prwhelan, I've created a changelog YAML for you.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 14, 2026

🔍 Preview links for changed docs

⏳ Building and deploying preview... View progress

This comment will be updated with preview links when the build is complete.

@github-actions
Copy link
Copy Markdown
Contributor

ℹ️ Important: Docs version tagging

👋 Thanks for updating the docs! Just a friendly reminder that our docs are now cumulative. This means all 9.x versions are documented on the same page and published off of the main branch, instead of creating separate pages for each minor version.

We use applies_to tags to mark version-specific features and changes.

Expand for a quick overview

When to use applies_to tags:

✅ At the page level to indicate which products/deployments the content applies to (mandatory)
✅ When features change state (e.g. preview, ga) in a specific version
✅ When availability differs across deployments and environments

What NOT to do:

❌ Don't remove or replace information that applies to an older version
❌ Don't add new information that applies to a specific version without an applies_to tag
❌ Don't forget that applies_to tags can be used at the page, section, and inline level

🤔 Need help?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes ML usage reporting to avoid a potential NullPointerException when trained model size stats have not yet been computed, by omitting those uncomputed stats from the aggregated usage output.

Changes:

  • Add a null-check around modelSizeStats when aggregating trained model memory usage in ML usage reporting.
  • Add a unit test covering the case where modelSizeStats is null.
  • Add a changelog entry for the bug fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearningUsageTransportAction.java Avoids NPE by skipping memory aggregation when modelSizeStats is missing.
x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MachineLearningUsageTransportActionTests.java Adds regression test for null modelSizeStats.
docs/changelog/146186.yaml Documents the bug fix in the changelog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@edsavage edsavage left a comment

Choose a reason for hiding this comment

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

LGTM

@prwhelan prwhelan enabled auto-merge (squash) April 15, 2026 12:14
@prwhelan prwhelan merged commit a7d3931 into elastic:main Apr 15, 2026
35 checks passed
prwhelan added a commit to prwhelan/elasticsearch that referenced this pull request Apr 15, 2026
There is a chance that a model does not have its stats computed when
usage is called, potentially throwing a NullPointerException. Usage will
now skip models that do not have stats yet.
prwhelan added a commit to prwhelan/elasticsearch that referenced this pull request Apr 15, 2026
There is a chance that a model does not have its stats computed when
usage is called, potentially throwing a NullPointerException. Usage will
now skip models that do not have stats yet.
prwhelan added a commit to prwhelan/elasticsearch that referenced this pull request Apr 15, 2026
There is a chance that a model does not have its stats computed when
usage is called, potentially throwing a NullPointerException. Usage will
now skip models that do not have stats yet.
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

💚 Backport successful

Status Branch Result
9.2
8.19
9.3
9.4
prwhelan added a commit to prwhelan/elasticsearch that referenced this pull request Apr 15, 2026
There is a chance that a model does not have its stats computed when
usage is called, potentially throwing a NullPointerException. Usage will
now skip models that do not have stats yet.
elasticsearchmachine pushed a commit that referenced this pull request Apr 15, 2026
There is a chance that a model does not have its stats computed when
usage is called, potentially throwing a NullPointerException. Usage will
now skip models that do not have stats yet.
elasticsearchmachine pushed a commit that referenced this pull request Apr 15, 2026
There is a chance that a model does not have its stats computed when
usage is called, potentially throwing a NullPointerException. Usage will
now skip models that do not have stats yet.
elasticsearchmachine pushed a commit that referenced this pull request Apr 15, 2026
There is a chance that a model does not have its stats computed when
usage is called, potentially throwing a NullPointerException. Usage will
now skip models that do not have stats yet.
elasticsearchmachine pushed a commit that referenced this pull request Apr 15, 2026
There is a chance that a model does not have its stats computed when
usage is called, potentially throwing a NullPointerException. Usage will
now skip models that do not have stats yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged >bug :ml Machine learning Team:ML Meta label for the ML team v8.19.15 v9.2.9 v9.3.4 v9.4.1 v9.5.0

4 participants