refactor: add vector validation to OpenSearchDB to ensure non‑null, non‑empty, and correct‑dimension vectors#4472
Merged
kartik-mem0 merged 1 commit intomainfrom Mar 21, 2026
Conversation
…on‑empty, and correct‑dimension vectors
whysosaket
reviewed
Mar 21, 2026
| payloads = [{} for _ in range(len(vectors))] | ||
|
|
||
| for idx, vec in enumerate(vectors): | ||
| if vec is None: |
Member
There was a problem hiding this comment.
Approving this for now, but need to soon figure out a better structure for sanitization and avoid the use of conditionals in the main function as much as possible
whysosaket
approved these changes
Mar 21, 2026
lukaj99
added a commit
to lukaj99/mem0
that referenced
this pull request
Mar 21, 2026
…on‑empty, and correct‑dimension vectors (mem0ai#4472)
jamebobob
pushed a commit
to jamebobob/mem0-vigil-recall
that referenced
this pull request
Mar 29, 2026
…on‑empty, and correct‑dimension vectors (mem0ai#4472)
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.
Description
Fixes the OpenSearch mapper_parsing_exception caused by null vectors and embedding dimension mismatches. Adds pre-insert/update vector validation with clear error messages, improves error logging
with full stack traces (exc_info=True), and fixes a silent except Exception: pass in the update() method that was swallowing all errors.
Fixes #3677
Type of change
How Has This Been Tested?
9 new tests added covering null vectors, empty vectors, dimension mismatches (insert + update), empty update vectors, and exc_info logging verification (insert, search, update). Full suite: 855
passed, 0 failed on Python 3.12 via hatch -e dev_py_3_12 run test.
Checklist:
Maintainer Checklist