From f586dd0a961082d69f6e37b2f395827069d4027e Mon Sep 17 00:00:00 2001 From: "wenxuan.zhang" Date: Tue, 1 Jul 2025 17:38:11 +0800 Subject: [PATCH] Fix: docx parse error. (#8600) ### What problem does this PR solve? docx parse error. ![image](https://github.com/user-attachments/assets/efbe6d1b-10c8-415e-b693-a86f73e1ffa6) ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) ### What problem does this PR solve? Some docx parse with naive cause error. `block.style.name` in Function `__get_nearest_title` will be None in some case. ### Type of change - [ ] Bug Fix (non-breaking change which fixes an issue) Co-authored-by: wenxuan.zhang --- rag/app/naive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rag/app/naive.py b/rag/app/naive.py index 809da121d..1fd661b09 100644 --- a/rag/app/naive.py +++ b/rag/app/naive.py @@ -121,7 +121,7 @@ class Docx(DocxParser): if block_type != 'p': continue - if block.style and re.search(r"Heading\s*(\d+)", block.style.name, re.I): + if block.style and block.style.name and re.search(r"Heading\s*(\d+)", block.style.name, re.I): try: level_match = re.search(r"(\d+)", block.style.name) if level_match: