Skip to content

Fix NPE setting similarity on an nvidia text_embedding endpoint - #158503

Open
HuzaifaChaudary wants to merge 2 commits into
elastic:mainfrom
HuzaifaChaudary:nvidia-embeddings-null-dimensions
Open

HuzaifaChaudary wants to merge 2 commits into
elastic:mainfrom
HuzaifaChaudary:nvidia-embeddings-null-dimensions

Conversation

@HuzaifaChaudary

Copy link
Copy Markdown

Closes #157288

dimensions() is an Integer and stays null until the first embedding response comes back, and nvidia does not accept dimensions in the endpoint config. The guard compared it to an int with ==, which unboxes it, so setting similarity on an nvidia text_embedding endpoint always threw a 500.

Builds the updated settings first and compares them with equals instead, which is what JinaAIService already does in the same package.

The test creates a model with no dimensions and calls updateModelWithEmbeddingDetails. Without the change it fails with Cannot invoke "java.lang.Integer.intValue()" because the return value of NvidiaEmbeddingsServiceSettings.dimensions() is null.

The nvidia tests pass, 224 in 21 classes.

dimensions() is an Integer and stays null until the first embedding response
comes back , and nvidia does not accept dimensions in the config . the guard
compared it to an int with == , which unboxes , so setting similarity always
threw a 500 .

build the updated settings first and compare with equals instead , which is
what jinaai already does in the same package .

closes elastic#157288
Copilot AI lite review requested due to automatic review settings September 3, 2026 20:19
@elasticsearchmachine elasticsearchmachine added external-contributor Pull request authored by a developer outside the Elasticsearch team v9.6.0 needs:triage Requires assignment of a team area label labels Sep 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change is small, directly addresses the verified NPE root cause, and includes a focused regression test plus changelog entry.

Pull request overview

Fixes a NullPointerException when updating an NVIDIA text_embedding inference endpoint that has similarity set while dimensions is still null (before the first embedding response provides the size). The change makes the “no-op update” guard null-safe by comparing service settings objects via equals(...), preventing unintended Integer unboxing.

Changes:

  • Replace the primitive/auto-unboxing guard in NvidiaService.updateModelWithEmbeddingDetails with an equals(...) comparison of rebuilt service settings.
  • Add a regression test that exercises updating a model whose dimensions has not yet been set.
  • Add a changelog entry documenting the bug fix.
File summaries
File Description
x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/nvidia/NvidiaService.java Makes the “skip model recreation” check null-safe by comparing settings objects rather than unboxing dimensions.
x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/nvidia/NvidiaServiceTests.java Adds a regression test ensuring updateModelWithEmbeddingDetails works when dimensions is initially null.
docs/changelog/158503.yaml Records the fix in the changelog under Machine Learning.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@kingherc kingherc added the :SearchOrg/Inference Label for the Search Inference team label Sep 8, 2026
@elasticsearchmachine elasticsearchmachine added Team:Search - Inference and removed needs:triage Requires assignment of a team area label labels Sep 8, 2026
@elasticsearchmachine

Copy link
Copy Markdown
Collaborator

Pinging @elastic/search-inference-team (Team:Search - Inference)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor Pull request authored by a developer outside the Elasticsearch team :SearchOrg/Inference Label for the Search Inference team Team:Search - Inference v9.6.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NullPointerException creating an nvidia text_embedding inference endpoint when similarity is set (dimensions is null)

4 participants