Skip to content

refactor: add vector validation to OpenSearchDB to ensure non‑null, non‑empty, and correct‑dimension vectors#4472

Merged
kartik-mem0 merged 1 commit intomainfrom
fix/opensearch-vector-validation-3677
Mar 21, 2026
Merged

refactor: add vector validation to OpenSearchDB to ensure non‑null, non‑empty, and correct‑dimension vectors#4472
kartik-mem0 merged 1 commit intomainfrom
fix/opensearch-vector-validation-3677

Conversation

@kartik-mem0
Copy link
Copy Markdown
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Unit Test

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:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Maintainer Checklist

@kartik-mem0 kartik-mem0 requested a review from whysosaket March 21, 2026 14:44
payloads = [{} for _ in range(len(vectors))]

for idx, vec in enumerate(vectors):
if vec is None:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

@kartik-mem0 kartik-mem0 merged commit eb780f4 into main Mar 21, 2026
8 checks passed
lukaj99 added a commit to lukaj99/mem0 that referenced this pull request Mar 21, 2026
jamebobob pushed a commit to jamebobob/mem0-vigil-recall that referenced this pull request Mar 29, 2026
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.

Open Search: mapper_parsing_exception

2 participants