SplitPdfHook raises NotImplementedError while partitioning a DOC with an embedded encrypted PDF
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 58/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
Start with src/unstructured_client/_hooks/custom/split_pdf_hook.py around before_request() and src/unstructured_client/_hooks/custom/pdf_utils.py to trace why PDF preflight runs for this DOC input and which exceptions it handles. Check the hook and PDF utility tests, then reproduce with a DOC containing an embedded PDF if a sample is available. Done when non-PDF inputs reach the API without this client-side failure and unsupported encrypted PDFs still produce a clear error.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
When partitioning a legacy .doc Word document that contains an embedded PDF, the Python SDK's SplitPdfHook.before_request() can raise:
NotImplementedError: only Standard PDF encryption handler is available
This happens on the client, before the partition request reaches the Unstructured API. A normal .doc without the embedded PDF is successfully partitioned through the same setup. The embedded PDF opens in WPS without a password prompt, but appears to use a PDF encryption handler unsupported by pypdf.
The failure is surprising because the input being partitioned is a DOC file, not a PDF that the caller requested to split.
Environment
- Integration: self-hosted Dify 1.13.3, workflow Document Extractor node, calling a self-hosted Unstructured API.
- Failing process: Dify worker container.
- Python: 3.11 (from traceback).
unstructured-client: Dify 1.13.3'sapi/uv.lockpins 0.42.4 (the traceback'ssplit_pdf_hook.py:293matches this tag; actual installed package versions have not been separately confirmed).pypdf: Dify 1.13.3's lockfile pins 6.9.1 (actual installed version not separately confirmed).- No sample document attached because the source document is from an internal environment.
Steps to reproduce
- Prepare a legacy Word
.docwith an embedded PDF using an encryption/security handler thatpypdfdoes not support. In this report, the embedded PDF opens in WPS without requiring a password. - Upload the DOC to a Dify workflow's Document Extractor node configured to use Unstructured.
- The worker calls
unstructured.partition.api.partition_via_api(...)with the DOC content. - Observe the exception from the SDK request hook. A plain DOC without this embedded PDF works.
A standalone SDK reproduction to try with the same document:
from unstructured.partition.api import partition_via_api
elements = partition_via_api(
filename="problem.doc",
api_url="http://<unstructured-host>:8000/general/v0/general",
api_key="",
)
Actual behavior
Relevant traceback (local path prefix omitted):
unstructured_client/_hooks/sdkhooks.py:48, in before_request
out = hook.before_request(hook_ctx, request)
unstructured_client/_hooks/custom/split_pdf_hook.py:293, in before_request
pdf = pdf_utils.read_pdf(pdf_file)
unstructured_client/_hooks/custom/pdf_utils.py:42, in read_pdf
return PdfReader(pdf_file, strict=False)
pypdf/_reader.py:155, in __init__
self._handle_encryption(password)
pypdf/_reader.py:182, in _handle_encryption
self._encryption = Encryption.read(encrypt_entry, id1_entry)
pypdf/_encryption.py:1093, in read
raise NotImplementedError(
NotImplementedError: only Standard PDF encryption handler is available
In unstructured-client v0.42.4, pdf_utils.read_pdf() catches (PdfReadError, UnicodeDecodeError), but does not catch this NotImplementedError:
The calling hook is here (lines 279–293):
Expected behavior
For non-PDF inputs, PDF splitting/preflight should not abort partitioning because the payload contains an embedded/recognizable PDF structure. Ideally the SDK detects whether the top-level input is a PDF before attempting PdfReader, and lets non-PDF documents proceed to the server unchanged. For actual encrypted PDFs with unsupported handlers, a clear validation error may still be appropriate.
Possible workaround / suggested fix
The source shows the hook returns early if split_pdf_page is absent or "false", before invoking pdf_utils.read_pdf(). Passing split_pdf_page=False to partition_via_api() should therefore avoid this specific client-side traceback; we have not yet verified end-to-end parsing of the problematic document after applying it.
Could the client skip PDF preflight for non-PDF top-level files, and/or handle the NotImplementedError from pypdf more gracefully without silently accepting unsupported encrypted PDFs?
Additional context
Dify 1.13.3 calls the SDK from:
Dify 1.18.0 still pins unstructured-client==0.42.4 in its lockfile, so upgrading Dify alone has not been established as a fix.
- 主要言語
- Python
- スター
- 120
- フォーク
- 22
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 7
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Unstructured-IO/unstructured-python-client のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Unstructured-IO/unstructured-python-client#362 · コメント 1 件 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
Unstructured-IO/unstructured-python-client の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
didi/helixharness#18 ·
-
request-theme
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
LizardByte/ThemerrDB#9883 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
NousResearch/hermes-agent#149885 ·
メンテナーはふだん 1 日以内に返信
-
Set cache_ok = True on GUID TypeDecorator to enable SQLAlchemy query caching対応中かも @patelshivani2283-lab が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
fedora-infra/anitya#2157 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Project-MONAI/MONAI#9258 ·
メンテナーはふだん 3 日以内に返信