Skip to content

Fix NPE when metadata is null in MilvusVectorStore #4116

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

little-huang
Copy link

Title

Guard against NPE when metadata is null during distance injection

Description

Adds a null check before injecting the distance property into metadata to prevent a NullPointerException if metadata is missing from the row record. The change is intentionally minimal and does not alter existing behavior beyond avoiding the crash.

Motivation / Background

Some search results do not carry metadata (or the metadata value is null). Calling JsonObject.addProperty(...) on a null reference throws an NPE and breaks the mapping pipeline.

Changes

Add a null guard around the distance injection step to ensure we do not call addProperty(...) on a null metadata.

Behavior

No functional changes other than preventing the NPE when metadata is null.

Related issues

Fixes #4115

@sobychacko
Copy link
Contributor

@little-huang
Copy link
Author

Please address the DCO commit signing. https://spring.io/blog/2025/01/06/hello-dco-goodbye-cla-simplifying-contributions-to-spring

Thanks, @sobychacko — signed off and force-pushed. DCO is green now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NullPointerException when metadata is null during distance injection in Document mapping
2 participants