Fix NPE setting similarity on an nvidia text_embedding endpoint - #158503
Open
HuzaifaChaudary wants to merge 2 commits into
Open
HuzaifaChaudary wants to merge 2 commits into
HuzaifaChaudary wants to merge 2 commits into
Conversation
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
Contributor
There was a problem hiding this comment.
🟢 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.updateModelWithEmbeddingDetailswith anequals(...)comparison of rebuilt service settings. - Add a regression test that exercises updating a model whose
dimensionshas 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.
Collaborator
|
Pinging @elastic/search-inference-team (Team:Search - Inference) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #157288
dimensions()is anIntegerand stays null until the first embedding response comes back, and nvidia does not acceptdimensionsin the endpoint config. The guard compared it to anintwith==, which unboxes it, so settingsimilarityon an nvidiatext_embeddingendpoint always threw a 500.Builds the updated settings first and compares them with
equalsinstead, which is whatJinaAIServicealready does in the same package.The test creates a model with no dimensions and calls
updateModelWithEmbeddingDetails. Without the change it fails withCannot invoke "java.lang.Integer.intValue()" because the return value of NvidiaEmbeddingsServiceSettings.dimensions() is null.The nvidia tests pass, 224 in 21 classes.