load_artifacts splits a Word (.docx) paragraph into several lines at spell-check marks
維護者通常 3 天內回覆
評估
這個 Issue 還沒有評估資料。
描述
🔴 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.
- 主要語言
- Python
- 星號
- 22.3k
- 分支
- 4.4k
- 平均合併
- 1 天 2 小時
- 30 天內合併 PR
- 6
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
google/adk-python 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
google/adk-python#8360 ·
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
google/adk-python#8359 ·
維護者通常 3 天內回覆
-
Can pin to litellm version be changed?可能已有人在做 @llalitkumarrr 於 10 天前認領。 未關閉models
難度 1/5 1 小時以內 新手友好度 65/100
google/adk-python#8129 · 2 則留言 · 已指派 1 人 ·
維護者通常 3 天內回覆
-
OpenAPI tools ignore operation- and path-level server overrides可能已有人在做 @sanketpatil06 於 14 天前認領。 未關閉tools
難度 2/5 1-3 小時 新手友好度 75/100
google/adk-python#8064 · 4 則留言 · 已指派 1 人 ·
維護者通常 3 天內回覆
-
Two docstrings in openapi_tool document parameters the signatures do not accept可能已有人在做 @surajksharma07 於 17 天前認領。 未關閉
難度 1/5 1 小時以內 新手友好度 88/100
google/adk-python#8024 · 1 則留言 · 已指派 1 人 ·
維護者通常 3 天內回覆
查看 google/adk-python 的全部 Issue
相似的 Issue
-
🧫10장-투향
難度 2/5 1-3 小時 新手友好度 65/100
hyunjimoon/golden-cage-book#188 ·
-
agent/scanner bug stage/010-actionable
難度 1/5 1 小時以內 新手友好度 88/100
torch-spyre/spyre-inference#1812 ·
維護者通常 1 天內回覆
-
Bug: fenced drafts inside <think> tags break parsing or are returned instead of the answer可能已有人在做 @aad1tyaaaaa 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
google/langextract#639 ·
維護者通常 1 天內回覆
-
[oblt-aw][autodoc] Update autodoc routing docs for relative in-repo lock uses可能已有人在做 @github-actions 今天認領。 未關閉
難度 1/5 1-3 小時 新手友好度 87/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆