load_artifacts splits a Word (.docx) paragraph into several lines at spell-check marks
Maintainer thường phản hồi trong vòng 3 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
🔴 Required Information
Describe the Bug:
LoadArtifactsTool breaks a paragraph of a Word document into several lines wherever Word has flagged a misspelled word.
_try_extract_docx_text in src/google/adk/tools/load_artifacts_tool.py splits word/document.xml into paragraphs with:
re.split(rf'<{p_tag}(?:[^>]*)>', xml_content)
With the usual w prefix this is <w:p(?:[^>]*)>. There is no check that the tag name ends after w:p, so it also matches every tag whose name merely starts with w:p: <w:proofErr>, <w:pPr>, <w:permStart>, <w:pgSz> and others. Word writes a <w:proofErr w:type="spellStart"/> / <w:proofErr w:type="spellEnd"/> pair around each word its spell checker flags, inside the paragraph, so the paragraph is split at both marks.
Steps to Reproduce:
- In Microsoft Word, type two paragraphs, with at least one misspelled word (red underline), and save as
report.docx:The quick brwn fox jumps ovr the lazy dog.Second paragraph is spelt corectly.
- Run:
from google.adk.tools.load_artifacts_tool import _try_extract_docx_text
print(repr(_try_extract_docx_text(open('report.docx', 'rb').read())))
The same text reaches the model when the file is saved as an artifact and loaded through load_artifacts with a Runner.
A self-contained reproduction without Word:
import io, zipfile
from google.adk.tools.load_artifacts_tool import _try_extract_docx_text
W = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'
body = (
'<w:p><w:r><w:t xml:space="preserve">The quick </w:t></w:r>'
'<w:proofErr w:type="spellStart"/><w:r><w:t>brwn</w:t></w:r>'
'<w:proofErr w:type="spellEnd"/>'
'<w:r><w:t xml:space="preserve"> fox jumps.</w:t></w:r></w:p>'
'<w:p><w:r><w:t>Second paragraph.</w:t></w:r></w:p>'
)
buf = io.BytesIO()
with zipfile.ZipFile(buf, 'w') as zf:
zf.writestr(
'word/document.xml',
f'<w:document xmlns:w="{W}"><w:body>{body}</w:body></w:document>',
)
print(repr(_try_extract_docx_text(buf.getvalue())))
Expected Behavior:
One line per paragraph:
'The quick brwn fox jumps ovr the lazy dog.\nSecond paragraph is spelt corectly.'
Observed Behavior:
With the file saved from Word (it contains six <w:proofErr> tags, two per flagged word):
'The quick \nbrwn\n fox jumps \novr\n the lazy dog.\nSecond paragraph is spelt \ncorectly\n.'
The self-contained reproduction prints 'The quick \nbrwn\n fox jumps.\nSecond paragraph.'.
No error is raised; the model just receives the document with extra line breaks.
Environment Details:
- ADK Library Version (pip show google-adk): 2.14.1, also current
main(d05e482) - Desktop OS: Windows 11 (the code path is not OS-specific)
- Python Version (python -V): 3.12
- Document saved with Microsoft Word 16.0 (Microsoft 365)
Model Information:
- Are you using LiteLLM: No
- Which model is being used: N/A, the text is wrong before it reaches any model
🟡 Optional Information
Regression:
Not known. I have not checked earlier releases.
Additional Context:
A one-line change fixes it by requiring the tag name to end after the paragraph tag: rf'<{p_tag}(?=[\s/>])[^>]*>'. I have a PR ready with a regression test.
Related but separate: #7088 changes the next line of the same function (entity decoding) and does not touch the split.
How often has this issue occurred?:
- Always (100%), for any paragraph containing a word flagged by Word's spell checker
Prepared with AI assistance (Claude Code); I reproduced it with a file saved from Word.
- Ngôn ngữ chính
- Python
- Star
- 22.3k
- Fork
- 4.4k
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của google/adk-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
google/adk-python#8360 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
google/adk-python#8359 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Can pin to litellm version be changed?Có thể đã có người làm @llalitkumarrr đã nhận 10 ngày trước. Đang mởmodels
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
google/adk-python#8129 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
OpenAPI tools ignore operation- and path-level server overridesCó thể đã có người làm @sanketpatil06 đã nhận 14 ngày trước. Đang mởtools
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
google/adk-python#8064 · 4 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Two docstrings in openapi_tool document parameters the signatures do not acceptCó thể đã có người làm @surajksharma07 đã nhận 17 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
google/adk-python#8024 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của google/adk-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
vllm-project/vllm#70030 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
TigreGotico/tugaphone#408 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
gke-labs/kube-agents#7308 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
t: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 3 ngày
-
chore
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
lugassawan/swe-workbench#841 ·