From 2fa8e3309f30fbe4ada5ec5136af29a99f377b9b Mon Sep 17 00:00:00 2001 From: Stephen Hu Date: Wed, 14 May 2025 10:13:03 +0800 Subject: [PATCH] Fix: file name length limit mismtach (#7630) ### What problem does this PR solve? Close #7597 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/db/services/file_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/db/services/file_service.py b/api/db/services/file_service.py index 367f39d82..60b51a0e4 100644 --- a/api/db/services/file_service.py +++ b/api/db/services/file_service.py @@ -432,7 +432,7 @@ class FileService(CommonService): MAX_FILE_NUM_PER_USER = int(os.environ.get('MAX_FILE_NUM_PER_USER', 0)) if MAX_FILE_NUM_PER_USER > 0 and DocumentService.get_doc_count(kb.tenant_id) >= MAX_FILE_NUM_PER_USER: raise RuntimeError("Exceed the maximum file number of a free user!") - if len(file.filename) >= 128: + if len(file.filename.encode("utf-8")) >= 128: raise RuntimeError("Exceed the maximum length of file name!") filename = duplicate_name(