Repository navigation
Description
Self Checks
- I have read the Contributing Guide and Language Policy.
- This is only for bug report, if you would like to ask a question, please head to Discussions.
- I have searched for existing issues search for existing issues, including closed ones.
- I confirm that I am using English to submit this report, otherwise it will be closed.
- 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
- Please do not modify this template :) and fill in all the required fields.
Dify version
Current main 80265fcfe110f0aea056fcb3566d322986014b78 (API package 1.18.0).
Cloud or Self Hosted
Self Hosted (Source). Reproduced against the production WordExtractor using a saved and reloaded DOCX package, not a deployed knowledge-base instance.
Steps to reproduce
Create a valid DOCX with a drawing that embeds a PNG through an image relationship whose target is word/media/logo.png. The image bytes and relationship type remain valid; the part name simply does not contain the substring image.
A minimal way to build such a package using python-docx and Pillow:
from io import BytesIO
from docx import Document
from docx.opc.constants import RELATIONSHIP_TYPE as RT
from docx.opc.packuri import PackURI
from PIL import Image
png = BytesIO()
Image.new('RGB', (2, 2), 'red').save(png, format='PNG')
png.seek(0)
doc = Document()
doc.add_paragraph('Before logo')
doc.add_picture(png)
doc.add_paragraph('After logo')
rel = next(r for r in doc.part.rels.values() if r.reltype == RT.IMAGE)
rel.target_part._partname = PackURI('/word/media/logo.png')
doc.save('logo.docx')Reloading the saved document with python-docx finds one inline drawing and the RT.IMAGE relationship targeting media/logo.png. Run WordExtractor('logo.docx', tenant_id, user_id, session=session).extract() with the usual storage/session dependencies.
✔️ Expected Behavior
The extractor stores the embedded PNG and includes its image-preview Markdown link between the surrounding paragraphs, regardless of whether the part name contains image.
❌ Actual Behavior
The production extractor returns only the surrounding paragraphs, with no image link or extracted image asset. _extract_images_from_docx() selects relationships using if "image" in rel.target_ref instead of the relationship type. The name-based check silently skips the valid media/logo.png relationship. Conversely, it also classifies non-image relationships as images when their target contains that substring.
Local output from the saved/reloaded package:
{
"target": "media/logo.png",
"loaded_inline_shapes": 1,
"extracted": "Before logo\n\n\nAfter logo",
"image_link_present": false
}From Codex
Activity
dosubot commentedon Oct 27, 2026
One additional scope detail: the filename check runs before the embedded/external branch, so external image relationships whose URLs lack
imageare skipped too, before any download is attempted. Both paragraph and table-cell rendering then omit images absent fromimage_map. [1] [2] [3]The existing extraction test uses
image1.pngandhttps://example.com/image.png, so both fixtures pass the substring check and do not exercise this case. Your saved/reloadedlogo.pngreproduction would make useful regression coverage, alongside an external image URL withoutimageand a non-image relationship whose target contains it. [4]To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.