Currently, CouchbaseVectorStore makes direct calls to the Couchbase Search service without internal exception handling. In production environments, transient issues (e.g., AmbiguousTimeoutException) or state issues (e.g., IndexNotFoundException during a rebalance) cause the entire RAG chain to fail.
Proposed Solution
I suggest wrapping the internal _search calls within similarity_search_with_score_by_vector with a custom retry/exception handler.
Logic Flow:
- Try the search operation.
- Except
AmbiguousTimeoutException, ServiceUnavailableException: Implement a simple exponential backoff retry (e.g., 3 attempts).
- Except
IndexNotFoundException:
- Log a
logger.warning stating the index is not yet ready.
- Return an empty list
[] to allow the RAG chain to continue without crashing.
- Except CouchbaseException: Log the specific internal error and re-raise as a standard RuntimeError (or a LangChain-native exception). This ensures that Couchbase-specific SDK details do not leak into the application layer for developers using the general VectorStore interface.