Document parsing error on doc extractor node #22042

Closed
opened 2026-02-21 20:15:25 -05:00 by yindo · 17 comments
Owner

Originally created by @raj-triforce on GitHub (Feb 3, 2026).

Originally assigned to: @fatelei on GitHub.

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

1.11.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Upload document file which have image linked via reference and image is not available in docx file upload this kind of file.

✔️ Expected Behavior

Doc extractor should receive the document and extract the remaining text ignoring the image. and it is happening when I edited the doc uploaded the newer image, and then tried to parse so it was working fine and gave me extracted text

Actual Behavior

Doc extractor is failing with this error message

Failed to extract text from DOCX: "There is no item named 'word/media/image1.png' in the archive"
There are 1 nodes in the process running abnormally, please go to tracing to check the logs.

Image
Originally created by @raj-triforce on GitHub (Feb 3, 2026). Originally assigned to: @fatelei on GitHub. ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.11.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Upload document file which have image linked via reference and image is not available in docx file upload this kind of file. ### ✔️ Expected Behavior Doc extractor should receive the document and extract the remaining text ignoring the image. and it is happening when I edited the doc uploaded the newer image, and then tried to parse so it was working fine and gave me extracted text ### ❌ Actual Behavior Doc extractor is failing with this error message Failed to extract text from DOCX: "There is no item named 'word/media/image1.png' in the archive" There are 1 nodes in the process running abnormally, please go to tracing to check the logs. <img width="449" height="859" alt="Image" src="https://github.com/user-attachments/assets/971dfe9e-9134-405a-b0b1-a3b20546c832" />
yindo added the 🐞 bug label 2026-02-21 20:15:25 -05:00
yindo closed this issue 2026-02-21 20:15:25 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 3, 2026):

This is a known issue in Dify v1.11.1: when a DOCX file references an image that is missing from the archive, the doc extractor fails with an error like "There is no item named 'word/media/image1.png' in the archive." This happens because the extractor assumes all referenced images exist and does not handle missing media gracefully, causing the underlying library to throw an exception and halt extraction rather than skipping the missing image and extracting the rest of the text (source).

A fix for this problem was merged after v1.11.1 (see PR #29558, merged 2025-12-12), which updates the extractor to handle missing images without failing the entire extraction process (source). Upgrading to a version that includes this fix will resolve the issue.

If you can't upgrade right away, a temporary workaround is to manually edit the DOCX file to remove or update any references to missing images before uploading.

Keep an eye on release notes for further improvements or configuration options related to DOCX extraction and error handling. If you need more technical details or help with a workaround, let me know!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Feb 3, 2026): <!-- Answer --> This is a known issue in Dify v1.11.1: when a DOCX file references an image that is missing from the archive, the doc extractor fails with an error like "There is no item named 'word/media/image1.png' in the archive." This happens because the extractor assumes all referenced images exist and does not handle missing media gracefully, causing the underlying library to throw an exception and halt extraction rather than skipping the missing image and extracting the rest of the text ([source](https://github.com/langgenius/dify/blob/c14a8bb4372dd303ec433cbbd730b395fb1aa0da/api/core/rag/extractor/word_extractor.py#L14-L403)). A fix for this problem was merged after v1.11.1 (see PR #29558, merged 2025-12-12), which updates the extractor to handle missing images without failing the entire extraction process ([source](https://github.com/langgenius/dify/pull/29558)). Upgrading to a version that includes this fix will resolve the issue. If you can't upgrade right away, a temporary workaround is to manually edit the DOCX file to remove or update any references to missing images before uploading. Keep an eye on release notes for further improvements or configuration options related to DOCX extraction and error handling. If you need more technical details or help with a workaround, let me know! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/8b2e756a-343f-423c-9ec6-c52388344c7b?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/8b2e756a-343f-423c-9ec6-c52388344c7b?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/8b2e756a-343f-423c-9ec6-c52388344c7b?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/8b2e756a-343f-423c-9ec6-c52388344c7b?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/8b2e756a-343f-423c-9ec6-c52388344c7b?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/8b2e756a-343f-423c-9ec6-c52388344c7b?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/8b2e756a-343f-423c-9ec6-c52388344c7b?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20a%20known%20issue%20in%20Dify%20v1.11.1%3A%20when%20a%20DOCX%20file%20references%20an%20image%20that%20is%20missing%20from%20the%20archive%2C%20the%20doc%20extractor%20fails%20with%20an%20error%20like%20%22There%20is%20no%20item%20named%20%27word/media/image1.png%27%20in%20the%20archive.%22%20This%20happens%20because%20the%20extractor%20assumes%20all%20referenced%20images%20exist%20and%20does%20not%20handle%20missing%20media%20gracefully%2C%20causing%20the%20underlying%20library%20to%20throw%20an%20exception%20and%20halt%20extraction%20rather%20than%20skipping%20the%20missing%20image%20and%20extracting%20the%20rest%20of%20the%20text%C2%A0%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/c14a8bb4372dd303ec433cbbd730b395fb1aa0da/api/core/rag/extractor/word_extractor.py%23L14-L403%29%29.%0A%0AA%20fix%20for%20this%20problem%20was%20merged%20after%20v1.11.1%20%28see%20PR%20%2329558%2C%20merged%202025-12-12%29%2C%20which%20updates%20the%20extractor%20to%20handle%20missing%20images%20without%20failing%20the%20entire%20extraction%20process%C2%A0%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/pull/29558%29%29.%20Upgrading%20to%20a%20version%20that%20includes%20this%20fix%20will%20resolve%20the%20issue.%0A%0AIf%20you%20can%27t%20upgrade%20right%20away%2C%20a%20temporary%20workaround%20is%20to%20manually%20edit%20the%20DOCX%20file%20to%20remove%20or%20update%20any%20references%20to%20missing%20images%20before%20uploading.%20%0A%0AKeep%20an%20eye%20on%20release%20notes%20for%20further%20improvements%20or%20configuration%20options%20related%20to%20DOCX%20extraction%20and%20error%20handling.%20If%20you%20need%20more%20technical%20details%20or%20help%20with%20a%20workaround%2C%20let%20me%20know%21)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31885)
Author
Owner

@raj-triforce commented on GitHub (Feb 3, 2026):

@dosu so upgrading to latest version will solve this issue ?

@raj-triforce commented on GitHub (Feb 3, 2026): @dosu so upgrading to latest version will solve this issue ?
Author
Owner

@dosubot[bot] commented on GitHub (Feb 3, 2026):

Upgrading to the latest version may not fully solve this issue yet. The fix for handling missing images in DOCX extraction was merged after v1.11.1, but a review of the latest code shows that the missing-media handling hasn't fully propagated—so the extractor can still fail if a referenced image is missing from the archive (source).

Until a confirmed fix is released, the best workaround is to manually remove or update any references to missing images in your DOCX files before uploading. Keep an eye on future releases or changelogs for explicit confirmation that this bug is resolved. If you need help with a workaround or want technical details, let me know!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Feb 3, 2026): <!-- Answer --> Upgrading to the latest version may not fully solve this issue yet. The fix for handling missing images in DOCX extraction was merged after v1.11.1, but a review of the latest code shows that the missing-media handling hasn't fully propagated—so the extractor can still fail if a referenced image is missing from the archive ([source](https://github.com/langgenius/dify/blob/c14a8bb4372dd303ec433cbbd730b395fb1aa0da/api/core/rag/extractor/word_extractor.py#L71-L403)). Until a confirmed fix is released, the best workaround is to manually remove or update any references to missing images in your DOCX files before uploading. Keep an eye on future releases or changelogs for explicit confirmation that this bug is resolved. If you need help with a workaround or want technical details, let me know! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/aae0717a-3169-435d-838b-7ae27ee50533?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/aae0717a-3169-435d-838b-7ae27ee50533?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/aae0717a-3169-435d-838b-7ae27ee50533?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/aae0717a-3169-435d-838b-7ae27ee50533?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/aae0717a-3169-435d-838b-7ae27ee50533?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/aae0717a-3169-435d-838b-7ae27ee50533?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/aae0717a-3169-435d-838b-7ae27ee50533?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Upgrading%20to%20the%20latest%20version%20may%20not%20fully%20solve%20this%20issue%20yet.%20The%20fix%20for%20handling%20missing%20images%20in%20DOCX%20extraction%20was%20merged%20after%20v1.11.1%2C%20but%20a%20review%20of%20the%20latest%20code%20shows%20that%20the%20missing-media%20handling%20hasn%27t%20fully%20propagated%E2%80%94so%20the%20extractor%20can%20still%20fail%20if%20a%20referenced%20image%20is%20missing%20from%20the%20archive%C2%A0%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/c14a8bb4372dd303ec433cbbd730b395fb1aa0da/api/core/rag/extractor/word_extractor.py%23L71-L403%29%29.%20%0A%0AUntil%20a%20confirmed%20fix%20is%20released%2C%20the%20best%20workaround%20is%20to%20manually%20remove%20or%20update%20any%20references%20to%20missing%20images%20in%20your%20DOCX%20files%20before%20uploading.%20Keep%20an%20eye%20on%20future%20releases%20or%20changelogs%20for%20explicit%20confirmation%20that%20this%20bug%20is%20resolved.%20If%20you%20need%20help%20with%20a%20workaround%20or%20want%20technical%20details%2C%20let%20me%20know%21)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31885)
Author
Owner

@raj-triforce commented on GitHub (Feb 3, 2026):

@dosu if you know exactly where in code it is happening, so it'll be helpful, fast, and help appreciated and I'll fix.

@raj-triforce commented on GitHub (Feb 3, 2026): @dosu if you know exactly where in code it is happening, so it'll be helpful, fast, and help appreciated and I'll fix.
Author
Owner

@dosubot[bot] commented on GitHub (Feb 3, 2026):

The error happens in the _extract_images_from_docx function in api/core/rag/extractor/word_extractor.py (around line 130) when the code tries to access rel.target_part.blob for internal images. If the referenced image is missing from the DOCX archive, this raises an exception and aborts extraction because there's no error handling here see source.

To fix it, wrap the internal image handling block with a try/except so missing images are skipped and extraction continues. For example:

else:
    image_ext = rel.target_ref.split(".")[-1]
    if image_ext is None:
        continue
    file_uuid = str(uuid.uuid4())
    file_key = "image_files/" + self.tenant_id + "/" + file_uuid + "." + image_ext
    mime_type, _ = mimetypes.guess_type(file_key)
    try:
        storage.save(file_key, rel.target_part.blob)
    except Exception as e:
        logger.warning("Failed to extract image %s: %s", rel.target_ref, str(e))
        continue
    # ... rest of the code to save file to db ...

This will let the extractor ignore missing images and extract the rest of the text as expected.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Feb 3, 2026): <!-- Answer --> The error happens in the `_extract_images_from_docx` function in `api/core/rag/extractor/word_extractor.py` (around line 130) when the code tries to access `rel.target_part.blob` for internal images. If the referenced image is missing from the DOCX archive, this raises an exception and aborts extraction because there's no error handling here [see source](https://github.com/langgenius/dify/blob/c14a8bb4372dd303ec433cbbd730b395fb1aa0da/api/core/rag/extractor/word_extractor.py#L87-L159). To fix it, wrap the internal image handling block with a `try/except` so missing images are skipped and extraction continues. For example: ```python else: image_ext = rel.target_ref.split(".")[-1] if image_ext is None: continue file_uuid = str(uuid.uuid4()) file_key = "image_files/" + self.tenant_id + "/" + file_uuid + "." + image_ext mime_type, _ = mimetypes.guess_type(file_key) try: storage.save(file_key, rel.target_part.blob) except Exception as e: logger.warning("Failed to extract image %s: %s", rel.target_ref, str(e)) continue # ... rest of the code to save file to db ... ``` This will let the extractor ignore missing images and extract the rest of the text as expected. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/b0c8f7e4-a8db-406a-b8a2-adaad251d22f?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/b0c8f7e4-a8db-406a-b8a2-adaad251d22f?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/b0c8f7e4-a8db-406a-b8a2-adaad251d22f?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/b0c8f7e4-a8db-406a-b8a2-adaad251d22f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/b0c8f7e4-a8db-406a-b8a2-adaad251d22f?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/b0c8f7e4-a8db-406a-b8a2-adaad251d22f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/b0c8f7e4-a8db-406a-b8a2-adaad251d22f?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20error%20happens%20in%20the%20%60_extract_images_from_docx%60%20function%20in%20%60api/core/rag/extractor/word_extractor.py%60%20%28around%20line%20130%29%20when%20the%20code%20tries%20to%20access%20%60rel.target_part.blob%60%20for%20internal%20images.%20If%20the%20referenced%20image%20is%20missing%20from%20the%20DOCX%20archive%2C%20this%20raises%20an%20exception%20and%20aborts%20extraction%20because%20there%27s%20no%20error%20handling%20here%C2%A0%5Bsee%20source%5D%28https%3A//github.com/langgenius/dify/blob/c14a8bb4372dd303ec433cbbd730b395fb1aa0da/api/core/rag/extractor/word_extractor.py%23L87-L159%29.%0A%0ATo%20fix%20it%2C%20wrap%20the%20internal%20image%20handling%20block%20with%20a%20%60try/except%60%20so%20missing%20images%20are%20skipped%20and%20extraction%20continues.%20For%20example%3A%0A%0A%60%60%60python%0Aelse%3A%0A%20%20%20%20image_ext%20%3D%20rel.target_ref.split%28%22.%22%29%5B-1%5D%0A%20%20%20%20if%20image_ext%20is%20None%3A%0A%20%20%20%20%20%20%20%20continue%0A%20%20%20%20file_uuid%20%3D%20str%28uuid.uuid4%28%29%29%0A%20%20%20%20file_key%20%3D%20%22image_files/%22%20%2B%20self.tenant_id%20%2B%20%22/%22%20%2B%20file_uuid%20%2B%20%22.%22%20%2B%20image_ext%0A%20%20%20%20mime_type%2C%20_%20%3D%20mimetypes.guess_type%28file_key%29%0A%20%20%20%20try%3A%0A%20%20%20%20%20%20%20%20storage.save%28file_key%2C%20rel.target_part.blob%29%0A%20%20%20%20except%20Exception%20as%20e%3A%0A%20%20%20%20%20%20%20%20logger.warning%28%22Failed%20to%20extract%20image%20%25s%3A%20%25s%22%2C%20rel.target_ref%2C%20str%28e%29%29%0A%20%20%20%20%20%20%20%20continue%0A%20%20%20%20%23%20...%20rest%20of%20the%20code%20to%20save%20file%20to%20db%20...%0A%60%60%60%0A%0AThis%20will%20let%20the%20extractor%20ignore%20missing%20images%20and%20extract%20the%20rest%20of%20the%20text%20as%20expected.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31885)
Author
Owner

@fatelei commented on GitHub (Feb 3, 2026):

Self Checks

  • I have read the Contributing Guide and Language Policy.[x] This is only for bug report, if you would like to ask a question, please head to Discussions.[x] I have searched for existing issues search for existing issues, including closed ones.[x] I confirm that I am using English to submit this report, otherwise it will be closed.[x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)[x] Please do not modify this template :) and fill in all the required fields.

Dify version

1.11.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Upload document file which have image linked via reference and image is not available in docx file upload this kind of file.

✔️ Expected Behavior

Doc extractor should receive the document and extract the remaining text ignoring the image. and it is happening when I edited the doc uploaded the newer image, and then tried to parse so it was working fine and gave me extracted text

Actual Behavior

Doc extractor is failing with this error message

Failed to extract text from DOCX: "There is no item named 'word/media/image1.png' in the archive" There are 1 nodes in the process running abnormally, please go to tracing to check the logs.

Image

how about your docx

@fatelei commented on GitHub (Feb 3, 2026): > ### Self Checks > * [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542).[x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general).[x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones.[x] I confirm that I am using English to submit this report, otherwise it will be closed.[x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)[x] Please do not modify this template :) and fill in all the required fields. > > ### Dify version > 1.11.1 > > ### Cloud or Self Hosted > Self Hosted (Docker) > > ### Steps to reproduce > Upload document file which have image linked via reference and image is not available in docx file upload this kind of file. > > ### ✔️ Expected Behavior > Doc extractor should receive the document and extract the remaining text ignoring the image. and it is happening when I edited the doc uploaded the newer image, and then tried to parse so it was working fine and gave me extracted text > > ### ❌ Actual Behavior > Doc extractor is failing with this error message > > Failed to extract text from DOCX: "There is no item named 'word/media/image1.png' in the archive" There are 1 nodes in the process running abnormally, please go to tracing to check the logs. > > <img alt="Image" width="449" height="859" src="https://private-user-images.githubusercontent.com/242341251/544349583-971dfe9e-9134-405a-b0b1-a3b20546c832.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzAxMjc0OTYsIm5iZiI6MTc3MDEyNzE5NiwicGF0aCI6Ii8yNDIzNDEyNTEvNTQ0MzQ5NTgzLTk3MWRmZTllLTkxMzQtNDA1YS1iMGIxLWEzYjIwNTQ2YzgzMi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMjAzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDIwM1QxMzU5NTZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mYjRmODQ0OTNiN2QzNGQ2MTg5NDhjZGQ3ZjUxZDJjMzEyOGYxMmJmODdiMDBlMzdjMzA0N2EyZjU0ZDZiMWE4JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.UlqdUtxvLjrQ2QBq-VJpufP4emHqNEDbnHCtX2Lt4CI"> how about your docx
Author
Owner

@raj-triforce commented on GitHub (Feb 4, 2026):

What do you mean by that? what about my docx, I didn't got you bro!

@raj-triforce commented on GitHub (Feb 4, 2026): What do you mean by that? what about my docx, I didn't got you bro!
Author
Owner

@fatelei commented on GitHub (Feb 4, 2026):

What do you mean by that? what about my docx, I didn't got you bro!

you can give me your docx, i test it

@fatelei commented on GitHub (Feb 4, 2026): > What do you mean by that? what about my docx, I didn't got you bro! you can give me your docx, i test it
Author
Owner

@raj-triforce commented on GitHub (Feb 5, 2026):

Sure!!

file-preview (3).docx

@raj-triforce commented on GitHub (Feb 5, 2026): Sure!! [file-preview (3).docx](https://github.com/user-attachments/files/25086812/file-preview.3.docx)
Author
Owner

@raj-triforce commented on GitHub (Feb 5, 2026):

hey @dosu after making changes how to rebuild the image?

@raj-triforce commented on GitHub (Feb 5, 2026): hey @dosu after making changes how to rebuild the image?
Author
Owner

@dosubot[bot] commented on GitHub (Feb 5, 2026):

To rebuild the Docker image after making code changes in your self-hosted Dify setup, run these commands from the docker directory:

docker compose build api
docker compose up -d api

If you also changed code used by the worker or worker_beat services, rebuild them too:

docker compose build worker worker_beat
docker compose up -d worker worker_beat

For frontend (web) changes, update docker-compose.yaml to use a local build context for the web service, then run:

docker compose up -d --build web

If you want to rebuild everything, use:

docker compose build
docker compose up -d

Stopping containers first with docker compose down is recommended if you want a clean restart. Your changes will take effect once the containers are back up. There’s no hot-reload—rebuilding and restarting is required for code changes to apply.
Reference

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Feb 5, 2026): <!-- Answer --> To rebuild the Docker image after making code changes in your self-hosted Dify setup, run these commands from the `docker` directory: ```bash docker compose build api docker compose up -d api ``` If you also changed code used by the worker or worker_beat services, rebuild them too: ```bash docker compose build worker worker_beat docker compose up -d worker worker_beat ``` For frontend (web) changes, update `docker-compose.yaml` to use a local build context for the `web` service, then run: ```bash docker compose up -d --build web ``` If you want to rebuild everything, use: ```bash docker compose build docker compose up -d ``` Stopping containers first with `docker compose down` is recommended if you want a clean restart. Your changes will take effect once the containers are back up. There’s no hot-reload—rebuilding and restarting is required for code changes to apply. [Reference](https://github.com/langgenius/dify/issues/30558#issuecomment-3709143799) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/c46ebd0e-dd3b-435d-bbb0-fe637f1c8e63?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/c46ebd0e-dd3b-435d-bbb0-fe637f1c8e63?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/c46ebd0e-dd3b-435d-bbb0-fe637f1c8e63?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/c46ebd0e-dd3b-435d-bbb0-fe637f1c8e63?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/c46ebd0e-dd3b-435d-bbb0-fe637f1c8e63?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/c46ebd0e-dd3b-435d-bbb0-fe637f1c8e63?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/c46ebd0e-dd3b-435d-bbb0-fe637f1c8e63?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=To%20rebuild%20the%20Docker%20image%20after%20making%20code%20changes%20in%20your%20self-hosted%20Dify%20setup%2C%20run%20these%20commands%20from%20the%20%60docker%60%20directory%3A%0A%0A%60%60%60bash%0Adocker%20compose%20build%20api%0Adocker%20compose%20up%20-d%20api%0A%60%60%60%0A%0AIf%20you%20also%20changed%20code%20used%20by%20the%20worker%20or%20worker_beat%20services%2C%20rebuild%20them%20too%3A%0A%0A%60%60%60bash%0Adocker%20compose%20build%20worker%20worker_beat%0Adocker%20compose%20up%20-d%20worker%20worker_beat%0A%60%60%60%0A%0AFor%20frontend%20%28web%29%20changes%2C%20update%20%60docker-compose.yaml%60%20to%20use%20a%20local%20build%20context%20for%20the%20%60web%60%20service%2C%20then%20run%3A%0A%0A%60%60%60bash%0Adocker%20compose%20up%20-d%20--build%20web%0A%60%60%60%0A%0AIf%20you%20want%20to%20rebuild%20everything%2C%20use%3A%0A%0A%60%60%60bash%0Adocker%20compose%20build%0Adocker%20compose%20up%20-d%0A%60%60%60%0A%0AStopping%20containers%20first%20with%20%60docker%20compose%20down%60%20is%20recommended%20if%20you%20want%20a%20clean%20restart.%20Your%20changes%20will%20take%20effect%20once%20the%20containers%20are%20back%20up.%20There%E2%80%99s%20no%20hot-reload%E2%80%94rebuilding%20and%20restarting%20is%20required%20for%20code%20changes%20to%20apply.%20%20%0A%5BReference%5D%28https%3A//github.com/langgenius/dify/issues/30558%23issuecomment-3709143799%29)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31885)
Author
Owner

@raj-triforce commented on GitHub (Feb 5, 2026):

hey, @dosu the real issue comes from the \api\core\workflow\nodes\document_extractor\node.py

and here is the code I've done, cause to docx.Document() was failing immediately as soon as the error was hitting about reference that func' couldn't found the defined image relation, so at that moment only we were getting failure, and even docx object was not even mounted and idk about any other library so i've tried to write the manual extraction if you think it is stable in production enough, please give me review about it.

@raj-triforce commented on GitHub (Feb 5, 2026): hey, @dosu the real issue comes from the \api\core\workflow\nodes\document_extractor\node.py and here is the code I've done, cause to docx.Document() was failing immediately as soon as the error was hitting about reference that func' couldn't found the defined image relation, so at that moment only we were getting failure, and even docx object was not even mounted and idk about any other library so i've tried to write the manual extraction if you think it is stable in production enough, please give me review about it.
Author
Owner

@raj-triforce commented on GitHub (Feb 5, 2026):

@dosu sorry forgot to provide you extension code which is just a fallback

def _extract_text_from_docx_manual(file_content: bytes) -> str:
"""
Manually extract text from DOCX by parsing ZIP and XML directly.
This bypasses python-docx completely and works even with missing images.
"""
try:
# Open DOCX as ZIP file
docx_zip = zipfile.ZipFile(io.BytesIO(file_content))

    # Read the main document XML
    try:
        document_xml = docx_zip.read('word/document.xml')
    except KeyError:
        logger.warning("Could not find word/document.xml in DOCX file")
        return ""
    
    # Parse XML
    try:
        tree = ET.fromstring(document_xml)
    except ET.ParseError as e:
        logger.warning("Failed to parse document.xml: %s", str(e))
        return ""
    
    # Define namespaces used in DOCX XML
    namespaces = {
        'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main',
        'v': 'urn:schemas-microsoft-com:vml',
        'wp': 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing',
        'a': 'http://schemas.openxmlformats.org/drawingml/2006/main',
        'pic': 'http://schemas.openxmlformats.org/drawingml/2006/picture'
    }
    
    text_parts = []
    
    # Extract text from paragraphs
    for paragraph in tree.findall('.//w:p', namespaces):
        para_texts = []
        
        # Get all text elements in the paragraph
        for text_elem in paragraph.findall('.//w:t', namespaces):
            if text_elem.text:
                para_texts.append(text_elem.text)
        
        # Join text from this paragraph
        para_text = ''.join(para_texts)
        if para_text.strip():
            text_parts.append(para_text)
    
    # Extract text from tables
    for table in tree.findall('.//w:tbl', namespaces):
        table_data = []
        
        for row in table.findall('.//w:tr', namespaces):
            row_data = []
            
            for cell in row.findall('.//w:tc', namespaces):
                cell_texts = []
                
                # Get all text in this cell
                for text_elem in cell.findall('.//w:t', namespaces):
                    if text_elem.text:
                        cell_texts.append(text_elem.text)
                
                cell_text = ''.join(cell_texts).replace('\n', ' ').strip()
                row_data.append(cell_text)
            
            if row_data and any(cell for cell in row_data):  # Skip empty rows
                table_data.append(row_data)
        
        # Convert table to markdown format
        if table_data:
            # Header row
            if len(table_data) > 0:
                header = table_data[0]
                markdown_table = '| ' + ' | '.join(header) + ' |\n'
                markdown_table += '| ' + ' | '.join(['---'] * len(header)) + ' |\n'
                
                # Data rows
                for row in table_data[1:]:
                    # Pad row if needed to match header length
                    while len(row) < len(header):
                        row.append('')
                    markdown_table += '| ' + ' | '.join(row[:len(header)]) + ' |\n'
                
                text_parts.append(markdown_table)
    
    return '\n'.join(text_parts)
    
except zipfile.BadZipFile:
    logger.warning("File is not a valid ZIP/DOCX file")
    return ""
except Exception as e:
    logger.warning("Manual DOCX text extraction failed: %s", str(e))
    return ""
@raj-triforce commented on GitHub (Feb 5, 2026): @dosu sorry forgot to provide you extension code which is just a fallback def _extract_text_from_docx_manual(file_content: bytes) -> str: """ Manually extract text from DOCX by parsing ZIP and XML directly. This bypasses python-docx completely and works even with missing images. """ try: # Open DOCX as ZIP file docx_zip = zipfile.ZipFile(io.BytesIO(file_content)) # Read the main document XML try: document_xml = docx_zip.read('word/document.xml') except KeyError: logger.warning("Could not find word/document.xml in DOCX file") return "" # Parse XML try: tree = ET.fromstring(document_xml) except ET.ParseError as e: logger.warning("Failed to parse document.xml: %s", str(e)) return "" # Define namespaces used in DOCX XML namespaces = { 'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main', 'v': 'urn:schemas-microsoft-com:vml', 'wp': 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing', 'a': 'http://schemas.openxmlformats.org/drawingml/2006/main', 'pic': 'http://schemas.openxmlformats.org/drawingml/2006/picture' } text_parts = [] # Extract text from paragraphs for paragraph in tree.findall('.//w:p', namespaces): para_texts = [] # Get all text elements in the paragraph for text_elem in paragraph.findall('.//w:t', namespaces): if text_elem.text: para_texts.append(text_elem.text) # Join text from this paragraph para_text = ''.join(para_texts) if para_text.strip(): text_parts.append(para_text) # Extract text from tables for table in tree.findall('.//w:tbl', namespaces): table_data = [] for row in table.findall('.//w:tr', namespaces): row_data = [] for cell in row.findall('.//w:tc', namespaces): cell_texts = [] # Get all text in this cell for text_elem in cell.findall('.//w:t', namespaces): if text_elem.text: cell_texts.append(text_elem.text) cell_text = ''.join(cell_texts).replace('\n', ' ').strip() row_data.append(cell_text) if row_data and any(cell for cell in row_data): # Skip empty rows table_data.append(row_data) # Convert table to markdown format if table_data: # Header row if len(table_data) > 0: header = table_data[0] markdown_table = '| ' + ' | '.join(header) + ' |\n' markdown_table += '| ' + ' | '.join(['---'] * len(header)) + ' |\n' # Data rows for row in table_data[1:]: # Pad row if needed to match header length while len(row) < len(header): row.append('') markdown_table += '| ' + ' | '.join(row[:len(header)]) + ' |\n' text_parts.append(markdown_table) return '\n'.join(text_parts) except zipfile.BadZipFile: logger.warning("File is not a valid ZIP/DOCX file") return "" except Exception as e: logger.warning("Manual DOCX text extraction failed: %s", str(e)) return ""
Author
Owner

@dosubot[bot] commented on GitHub (Feb 5, 2026):

Your manual DOCX extraction fallback is a solid approach for resilience: it reliably extracts text from paragraphs and tables even when images or relationships are missing, which is exactly where python-docx and Dify’s built-in extractors tend to fail example. This makes it a good safety net for corrupted or non-standard files.

A few things to keep in mind for production use:

  • This method only extracts paragraphs and tables. It will miss lists, headers/footers, comments, hyperlinks, and other advanced DOCX features reference.
  • Security: parsing ZIP/XML directly is generally safe, but consider adding checks for zip bombs (huge numbers of entries or very large files) and disabling XML entity expansion to avoid XXE attacks.
  • Performance: for very large documents, parsing the entire XML tree in memory can be slow or memory-intensive. If you expect large files, consider streaming or chunked parsing.
  • Integration: the best practice is to use this as a fallback—try python-docx first for richer extraction, and only use the manual method if that fails due to missing images or broken relationships reference.
  • Logging: your error handling is good—make sure logs are monitored so you can catch edge cases or unexpected failures.

For extra robustness, test with a variety of DOCX files: ones with lists, headers, comments, and intentionally broken relationships, to see what gets missed or triggers errors. If you need to support more DOCX features, you can extend the XML parsing to cover more tags, but that will add complexity.

Overall, your fallback is stable for simple documents and a practical way to avoid total extraction failure when files are imperfect.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Feb 5, 2026): <!-- Answer --> Your manual DOCX extraction fallback is a solid approach for resilience: it reliably extracts text from paragraphs and tables even when images or relationships are missing, which is exactly where python-docx and Dify’s built-in extractors tend to fail [example](https://github.com/langgenius/dify/issues/23967). This makes it a good safety net for corrupted or non-standard files. A few things to keep in mind for production use: - This method only extracts paragraphs and tables. It will miss lists, headers/footers, comments, hyperlinks, and other advanced DOCX features [reference](https://github.com/langgenius/dify/issues/24225). - Security: parsing ZIP/XML directly is generally safe, but consider adding checks for zip bombs (huge numbers of entries or very large files) and disabling XML entity expansion to avoid XXE attacks. - Performance: for very large documents, parsing the entire XML tree in memory can be slow or memory-intensive. If you expect large files, consider streaming or chunked parsing. - Integration: the best practice is to use this as a fallback—try python-docx first for richer extraction, and only use the manual method if that fails due to missing images or broken relationships [reference](https://github.com/langgenius/dify/blob/e04f2a0786df994168618abe1832a8ae921f6227/api/core/workflow/nodes/document_extractor/node.py#L38-L431). - Logging: your error handling is good—make sure logs are monitored so you can catch edge cases or unexpected failures. For extra robustness, test with a variety of DOCX files: ones with lists, headers, comments, and intentionally broken relationships, to see what gets missed or triggers errors. If you need to support more DOCX features, you can extend the XML parsing to cover more tags, but that will add complexity. Overall, your fallback is stable for simple documents and a practical way to avoid total extraction failure when files are imperfect. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/4d198edc-dc66-4d4a-8068-636de550a52b?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/4d198edc-dc66-4d4a-8068-636de550a52b?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/4d198edc-dc66-4d4a-8068-636de550a52b?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/4d198edc-dc66-4d4a-8068-636de550a52b?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/4d198edc-dc66-4d4a-8068-636de550a52b?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/4d198edc-dc66-4d4a-8068-636de550a52b?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/4d198edc-dc66-4d4a-8068-636de550a52b?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Your%20manual%20DOCX%20extraction%20fallback%20is%20a%20solid%20approach%20for%20resilience%3A%20it%20reliably%20extracts%20text%20from%20paragraphs%20and%20tables%20even%20when%20images%20or%20relationships%20are%20missing%2C%20which%20is%20exactly%20where%20python-docx%20and%20Dify%E2%80%99s%20built-in%20extractors%20tend%20to%20fail%C2%A0%5Bexample%5D%28https%3A//github.com/langgenius/dify/issues/23967%29.%20This%20makes%20it%20a%20good%20safety%20net%20for%20corrupted%20or%20non-standard%20files.%0A%0AA%20few%20things%20to%20keep%20in%20mind%20for%20production%20use%3A%0A%0A-%20This%20method%20only%20extracts%20paragraphs%20and%20tables.%20It%20will%20miss%20lists%2C%20headers/footers%2C%20comments%2C%20hyperlinks%2C%20and%20other%20advanced%20DOCX%20features%C2%A0%5Breference%5D%28https%3A//github.com/langgenius/dify/issues/24225%29.%0A-%20Security%3A%20parsing%20ZIP/XML%20directly%20is%20generally%20safe%2C%20but%20consider%20adding%20checks%20for%20zip%20bombs%20%28huge%20numbers%20of%20entries%20or%20very%20large%20files%29%20and%20disabling%20XML%20entity%20expansion%20to%20avoid%20XXE%20attacks.%0A-%20Performance%3A%20for%20very%20large%20documents%2C%20parsing%20the%20entire%20XML%20tree%20in%20memory%20can%20be%20slow%20or%20memory-intensive.%20If%20you%20expect%20large%20files%2C%20consider%20streaming%20or%20chunked%20parsing.%0A-%20Integration%3A%20the%20best%20practice%20is%20to%20use%20this%20as%20a%20fallback%E2%80%94try%20python-docx%20first%20for%20richer%20extraction%2C%20and%20only%20use%20the%20manual%20method%20if%20that%20fails%20due%20to%20missing%20images%20or%20broken%20relationships%C2%A0%5Breference%5D%28https%3A//github.com/langgenius/dify/blob/e04f2a0786df994168618abe1832a8ae921f6227/api/core/workflow/nodes/document_extractor/node.py%23L38-L431%29.%0A-%20Logging%3A%20your%20error%20handling%20is%20good%E2%80%94make%20sure%20logs%20are%20monitored%20so%20you%20can%20catch%20edge%20cases%20or%20unexpected%20failures.%0A%0AFor%20extra%20robustness%2C%20test%20with%20a%20variety%20of%20DOCX%20files%3A%20ones%20with%20lists%2C%20headers%2C%20comments%2C%20and%20intentionally%20broken%20relationships%2C%20to%20see%20what%20gets%20missed%20or%20triggers%20errors.%20If%20you%20need%20to%20support%20more%20DOCX%20features%2C%20you%20can%20extend%20the%20XML%20parsing%20to%20cover%20more%20tags%2C%20but%20that%20will%20add%20complexity.%0A%0AOverall%2C%20your%20fallback%20is%20stable%20for%20simple%20documents%20and%20a%20practical%20way%20to%20avoid%20total%20extraction%20failure%20when%20files%20are%20imperfect.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31885)
Author
Owner

@fatelei commented on GitHub (Feb 5, 2026):

This error occurs when python-docx tries to open a DOCX file that has a broken or corrupted internal structure. Specifically, the document's relationship XML references an image (word/media/image1.png) that doesn't actually exist in the ZIP archive.

here we can add a fallback method to solve it

@fatelei commented on GitHub (Feb 5, 2026): This error occurs when python-docx tries to open a DOCX file that has a broken or corrupted internal structure. Specifically, the document's relationship XML references an image (word/media/image1.png) that doesn't actually exist in the ZIP archive. here we can add a fallback method to solve it
Author
Owner

@fatelei commented on GitHub (Feb 5, 2026):

i have submit a pr, you can use the code in pr

@fatelei commented on GitHub (Feb 5, 2026): i have submit a pr, you can use the code in pr
Author
Owner

@raj-triforce commented on GitHub (Feb 9, 2026):

Okay, Thank you!!

@raj-triforce commented on GitHub (Feb 9, 2026): Okay, Thank you!!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#22042