From 83aca2d07b9dd1c304e581d8ef68b7aef4fcbc1c Mon Sep 17 00:00:00 2001 From: Jay Xu Date: Mon, 4 Aug 2025 15:36:31 +0800 Subject: [PATCH] fix #8424 NPE in dify_retrieval.py, add log exception (#9212) ### What problem does this PR solve? fix #8424 NPE in dify_retrieval.py, add log exception ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/apps/sdk/dify_retrieval.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/apps/sdk/dify_retrieval.py b/api/apps/sdk/dify_retrieval.py index f15eb2396..9723cabbf 100644 --- a/api/apps/sdk/dify_retrieval.py +++ b/api/apps/sdk/dify_retrieval.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import logging + from flask import request, jsonify from api.db import LLMType @@ -77,7 +79,7 @@ def retrieval(tenant_id): "content": c["content_with_weight"], "score": c["similarity"], "title": c["docnm_kwd"], - "metadata": doc.meta_fields + "metadata": getattr(doc, 'meta_fields', {}) }) return jsonify({"records": records}) @@ -87,4 +89,5 @@ def retrieval(tenant_id): message='No chunk found! Check the chunk status please!', code=settings.RetCode.NOT_FOUND ) + logging.exception(e) return build_error_result(message=str(e), code=settings.RetCode.SERVER_ERROR)