#2721·instructor

PDF.autodetect rejects raw Base64 input above the filename limit

Author: takiAACreated Sep 29, 2026Updated Sep 29, 2026

PDF.from_raw_base64() accepts a raw Base64 PDF, but PDF.autodetect() raises MultimodalError once the encoded string exceeds the filesystem's filename limit. With automatic media detection, the same input falls back to a text block instead of a document block.

Reproduced on main at e12f8b4, Instructor 1.17.1, macOS, Python 3.13.5. No model call is needed:

python
import base64
from instructor.processing.multimodal import PDF, autodetect_media

# Synthetic PDF header, matching the existing constructor tests.
encoded = base64.b64encode(b"%PDF-1.7\n" + b" " * 1024).decode("ascii")

print(PDF.from_raw_base64(encoded).media_type)  # application/pdf
print(type(autodetect_media(encoded)).__name__)  # str; expected PDF
PDF.autodetect(encoded)  # MultimodalError: PDF file name too long

The path probe raises ENAMETOOLONG before the raw-Base64 fallback is reached. That branch also uses the macOS-specific errno value 63 rather than errno.ENAMETOOLONG.

Expected: recognize the same PDF content as from_raw_base64(), regardless of the encoded string's length. A small fix can try the existing Base64 parser after ENAMETOOLONG, keeping the path error for input that is not a PDF. I have a patch with regression coverage for direct detection, automatic media detection, and Anthropic message conversion.