HKUDS/DeepTutor · error · LLMProviderTransportError

Unable to reach the model provider. Please retry.

Error message

Unable to reach the model provider. Please retry.

What it means

Raised by the PyMuPDF (fitz) branch of _extract_pdf when the PDF is encrypted and cannot be opened with an empty password (doc.authenticate("") fails). Password-protected PDFs cannot be text-extracted without credentials, so a CorruptDocumentError is raised with the filename attached.

Source

Thrown at deeptutor/agents/chat/agent_loop.py:787

                            "error_code": "provider_transport",
                            "retryable": True,
                            "partial_response": partial_response,
                        },
                    ),
                )
                message = self.pipeline._t(
                    (
                        "notices.provider_stream_interrupted"
                        if partial_response
                        else "notices.provider_unavailable"
                    ),
                    default=(
                        "The model provider interrupted this response. Please retry."
                        if partial_response
                        else "Unable to reach the model provider. Please retry."
                    ),
                )
                raise LLMProviderTransportError(
                    message,
                    partial_response=partial_response,
                ) from exc
            finally:
                close = getattr(response_stream, "close", None)
                if callable(close):
                    with suppress(Exception):
                        await close()
            break

        dsml_tail = dsml_filter.flush()
        if dsml_tail:
            await _emit_segments(think_filter.feed(dsml_tail))
        await _emit_segments(think_filter.flush())
        text = "".join(text_parts)
        record_streamed_usage(
            self.pipeline.usage,
            usage_seen,

View on GitHub (pinned to 3e82f13042)

Solutions

  1. Decrypt the PDF upstream (qpdf --decrypt in.pdf out.pdf) before ingestion
  2. Ask the uploader for the password, decrypt with pikepdf/pymupdf, then extract
  3. Catch CorruptDocumentError and report 'encrypted PDF' to the user / skip the file

Example fix

// before
text = _extract_pdf(data, "protected.pdf")

// after
import pikepdf
with pikepdf.open(io.BytesIO(data), password=pw) as pdf:
    buf = io.BytesIO()
    pdf.save(buf)
text = _extract_pdf(buf.getvalue(), "protected.pdf")
Defensive patterns

Strategy: try-catch

Validate before calling

import fitz
try:
    with fitz.open(stream=data, filetype="pdf") as doc:
        encrypted = doc.needs_pass
except Exception:
    encrypted = False
if encrypted:
    request_password_from_user()

Try / catch

from deeptutor.utils.document_extractor import CorruptDocumentError
try:
    text = extract_text_from_bytes(data, filename=fn)
except CorruptDocumentError as e:
    if "encrypted" in str(e):
        prompt_for_password(fn)  # then decrypt & retry

Prevention

When it happens

Trigger: Extracting a PDF with an owner password (restrictions) where authenticate("") returns 0; extracting a user-password-protected PDF via extract_text_from_bytes(data, filename='secret.pdf').

Common situations: Ingesting publisher-provided or DRM-ish ebooks, confidential documents, or PDFs exported with 'require password to open' options into a knowledge base.

Related errors


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/06a97cb6cfa69ae8. Report an issue: GitHub.