RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix(es): downgrade LLM-generated invalid SQL to WARNING in ES sql() (#15409) (#15709)
Rene Arredondo3f929e3904ad
diff --git a/common/doc_store/es_conn_base.py b/common/doc_store/es_conn_base.pyindex daa5f17770..5d1a718647 100644--- a/common/doc_store/es_conn_base.py+++ b/common/doc_store/es_conn_base.py@@ -21,7 +21,7 @@ import timeimport osfrom abc import abstractmethod-from elasticsearch import NotFoundError+from elasticsearch import BadRequestError, NotFoundErrorfrom elasticsearch_dsl import Indexfrom elastic_transport import ConnectionTimeoutfrom elasticsearch.client import IndicesClient@@ -395,6 +395,14 @@ class ESConnectionBase(DocStoreConnection):time.sleep(3)self._connect()continue+ except BadRequestError as e:+ # LLM-generated SQL routinely references columns that don't exist+ # (e.g. unknown_column / verification_exception). The caller in+ # api/db/services/dialog_service.py:use_sql catches this and either+ # re-prompts the LLM with the error or falls back to vector search,+ # so a full ERROR-level traceback is misleading — see #15409.+ self.logger.warning(f"ESConnection.sql rejected by ES (likely invalid LLM-generated SQL). SQL:\n{sql}\nError: {e}")+ raise Exception(f"SQL error: {e}\n\nSQL: {sql}")except Exception as e:self.logger.exception(f"ESConnection.sql got exception. SQL:\n{sql}")raise Exception(f"SQL error: {e}\n\nSQL: {sql}")