Skip to content

fix(vector_stores/elasticsearch): stop reading transport failures as missing vectors - #7530

Closed
siye566 wants to merge 1 commit into
mem0ai:mainfrom
siye566:fix/elasticsearch-get-transport-errors
Closed

siye566 wants to merge 1 commit into
mem0ai:mainfrom
siye566:fix/elasticsearch-get-transport-errors

Conversation

@siye566

@siye566 siye566 commented Oct 2, 2026

Copy link
Copy Markdown

{"body": "## What & Why\n\nElasticsearchDB.get() wrapped the client call and response parsing in one try whose blanket except Exception returned None for everything \u2014 including connection refusals, auth failures and cluster outages. None is what every caller reads as "no such vector", so a backend outage looked like missing data. The codebase already documents the opposite contract: _update_memory() in mem0/memory/main.py wraps vector_store.get() in except Exception: ... raise with the comment "Backing-store failure, not a bad memory_id: re-raise the original so the REST layer maps it to 5xx, not 4xx". The update() path is worse: None there inserts a duplicate row where the user asked for an update (#7516).\n\nFix: split get() into two phases \u2014\n\n- NotFoundError from the client call (a missing document, the only genuine "no such vector") returns None;\n- every other client-call failure logs and re-raises;\n- response parse-shape failures (KeyError/TypeError on _id/_source) keep degrading to None.\n\n## Tests\n\n- test_get_not_found now uses the real NotFoundError (it previously pinned the bug with a generic Exception(\"Not found\") \u2192 None).\n- New test_get_transport_error_propagates: a ConnectionError propagates (verified red on the old code).\n- New test_get_malformed_response_returns_none: missing _source and a None response still degrade to None.\n\nFull tests/vector_stores/test_elasticsearch.py: 24 passed (Python 3.12, elasticsearch 8.19.3). ruff check / ruff format --check clean.\n\nFixes #7516"}

…missing vectors

get() wrapped the client call and response parsing in the same try, so
its blanket `except Exception` turned connection refusals, auth failures
and cluster outages into None -- the same value a caller reads as "no
such vector". _update_memory's own handler already documents that a
backing-store failure must propagate (5xx, not 4xx), and a None here
makes the update path insert a duplicate instead of updating.

Split the two phases: NotFoundError (a missing document) still returns
None, transport/auth/server errors log and raise, and only response
parse-shape failures (KeyError/TypeError) degrade to None.

Fixes mem0ai#7516
@github-actions github-actions Bot added sdk-python Python SDK specific vector-store Vector store backends (Qdrant, PGVector, Redis, etc.) labels Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

Thanks for taking the time to open this.

We only review pull requests that fix an issue we have already agreed to take on, so this one is closed for now.
Closed does not mean rejected. It means it is not in the queue yet, and reopening takes about a minute.

To get it reviewed:

  1. Make sure an issue describes the problem, with the version you are on, a runnable reproduction, and the real output or traceback you saw.
  2. Link it from this pull request description with Closes #<number>.
  3. Ask a maintainer to label that issue accepted. This pull request reopens by itself when they do.

Issue already labeled accepted? Just add Closes #<number> to the description. That reopens this too.

Documentation-only changes skip this gate entirely.

See CONTRIBUTING.md for the full policy.

@github-actions github-actions Bot closed this Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

Hi @siye566, thanks for opening this pull request.

This is just a soft check: you are not yet in this repo's vouched contributor list (.github/VOUCHED.td). Nothing is blocked and there is nothing you need to do.

A maintainer can vouch for you by commenting !vouch @siye566 on any issue.

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

Labels

sdk-python Python SDK specific vector-store Vector store backends (Qdrant, PGVector, Redis, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant