Conversation
…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
|
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. To get it reviewed:
Issue already labeled Documentation-only changes skip this gate entirely. See CONTRIBUTING.md for the full policy. |
|
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 ( A maintainer can vouch for you by commenting |
{"body": "## What & Why\n\n
ElasticsearchDB.get()wrapped the client call and response parsing in onetrywhose blanketexcept ExceptionreturnedNonefor everything \u2014 including connection refusals, auth failures and cluster outages.Noneis 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()inmem0/memory/main.pywrapsvector_store.get()inexcept Exception: ... raisewith the comment "Backing-store failure, not a bad memory_id: re-raise the original so the REST layer maps it to 5xx, not 4xx". Theupdate()path is worse:Nonethere inserts a duplicate row where the user asked for an update (#7516).\n\nFix: splitget()into two phases \u2014\n\n-NotFoundErrorfrom the client call (a missing document, the only genuine "no such vector") returnsNone;\n- every other client-call failure logs and re-raises;\n- response parse-shape failures (KeyError/TypeErroron_id/_source) keep degrading toNone.\n\n## Tests\n\n-test_get_not_foundnow uses the realNotFoundError(it previously pinned the bug with a genericException(\"Not found\")\u2192None).\n- Newtest_get_transport_error_propagates: aConnectionErrorpropagates (verified red on the old code).\n- Newtest_get_malformed_response_returns_none: missing_sourceand aNoneresponse still degrade toNone.\n\nFulltests/vector_stores/test_elasticsearch.py: 24 passed (Python 3.12, elasticsearch 8.19.3).ruff check/ruff format --checkclean.\n\nFixes #7516"}