diff --git a/api/apps/document_app.py b/api/apps/document_app.py index 501b69068..642ff8b45 100644 --- a/api/apps/document_app.py +++ b/api/apps/document_app.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License # +import logging import os.path import re from pathlib import PurePosixPath, PureWindowsPath @@ -125,16 +126,20 @@ async def change_status(): search.index_name(kb.tenant_id), doc.kb_id, ) - except Exception as exc: - msg = str(exc) - if "3022" in msg: - result[doc_id] = {"error": "Document store table missing."} - else: - result[doc_id] = {"error": f"Document store update failed: {msg}"} + except Exception: + logging.exception( + "Document store update failed in change_status: doc_id=%s kb_id=%s status=%s", + doc_id, doc.kb_id, status_int, + ) + result[doc_id] = {"error": "Document store update failed."} has_error = True continue if not ok: - result[doc_id] = {"error": "Database error (docStore update)!"} + logging.warning( + "Document store update returned False in change_status: doc_id=%s kb_id=%s status=%s", + doc_id, doc.kb_id, status_int, + ) + result[doc_id] = {"error": "Document store table missing or update failed."} has_error = True continue result[doc_id] = {"status": status} diff --git a/memory/utils/infinity_conn.py b/memory/utils/infinity_conn.py index 93402fa1a..ae350c0c8 100644 --- a/memory/utils/infinity_conn.py +++ b/memory/utils/infinity_conn.py @@ -440,7 +440,14 @@ class InfinityConnection(InfinityConnectionBase): try: db_instance = inf_conn.get_database(self.dbName) table_name = f"{index_name}_{memory_id}" - table_instance = db_instance.get_table(table_name) + try: + table_instance = db_instance.get_table(table_name) + except InfinityException as e: + # src/common/status.cppm, kTableNotExist = 3022 + if e.error_code == ErrorCode.TABLE_NOT_EXIST: + self.logger.warning(f"Table {table_name} does not exist, skipping update.") + return False + raise columns = {} if table_instance: diff --git a/rag/utils/infinity_conn.py b/rag/utils/infinity_conn.py index d68cd8800..45290c520 100644 --- a/rag/utils/infinity_conn.py +++ b/rag/utils/infinity_conn.py @@ -485,7 +485,14 @@ class InfinityConnection(InfinityConnectionBase): table_name = index_name else: table_name = f"{index_name}_{knowledgebase_id}" - table_instance = db_instance.get_table(table_name) + try: + table_instance = db_instance.get_table(table_name) + except InfinityException as e: + # src/common/status.cppm, kTableNotExist = 3022 + if e.error_code == ErrorCode.TABLE_NOT_EXIST: + self.logger.warning(f"Table {table_name} does not exist, skipping update.") + return False + raise # if "exists" in condition: # del condition["exists"]