langflow-ai/langflow · warning · HTTPException
Binary content not supported
Error message
Binary content not supported
What it means
The agentic file router serves text content only: after the binary sniff, _looks_binary(head) checks for a null byte in the first BINARY_SNIFF_BYTES. If found, it raises HTTP 415 'Binary content not supported' — the same heuristic the FS tool uses — because returning raw bytes through this text-oriented endpoint would corrupt responses.
Source
Thrown at src/backend/base/langflow/agentic/api/files_router.py:175
resolved.exists(),
resolved.is_dir(),
)
raise HTTPException(status_code=404, detail="Not found")
try:
size = resolved.stat().st_size
except OSError:
raise HTTPException(status_code=404, detail="Not found") from None
if size > MAX_FILE_SIZE_BYTES:
raise HTTPException(status_code=413, detail="File too large")
# Binary sniff before the full read — same heuristic the FS tool uses.
try:
head = _read_head_no_follow(resolved, BINARY_SNIFF_BYTES)
except (OSError, PermissionError):
raise HTTPException(status_code=404, detail="Not found") from None
if _looks_binary(head):
raise HTTPException(status_code=415, detail="Binary content not supported")
try:
body_bytes = _read_bytes_no_follow(resolved)
except (OSError, PermissionError):
raise HTTPException(status_code=404, detail="Not found") from None
# Audit log — relative path only, never the absolute sandbox-resolved path.
logger.info(
"agentic.files.read user_id=%s path=%s size=%d download=%s",
current_user.id,
path,
len(body_bytes),
download,
)
if download:
filename = _safe_filename_for_disposition(path) or "file"
return Response(View on GitHub (pinned to 976ec789d2)
Solutions
- Use a binary-capable path (the download/attachment flow or the storage service) for non-text artifacts.
- Instruct the agent to write textual formats (markdown/json/csv) for files intended to be read via this endpoint.
- Treat 415 as final for that file — retrying will not change the sniff result.
Defensive patterns
Strategy: validation
Validate before calling
SNIFF = 8192
with open(sandbox_path, "rb") as f:
looks_binary = b"\x00" in f.read(SNIFF)
if looks_binary:
use_download_flow(sandbox_path) Try / catch
if resp.status_code == 415:
switch_to_binary_transfer(path) # sniff is deterministic; retries are useless Prevention
- Reserve this endpoint for text formats (md/json/csv/txt).
- Instruct agents to persist artifacts as text when they will be inlined.
- Use the attachment/download path for images, archives, and serialized objects.
When it happens
Trigger: GET /api/v1/agentic/files on a .png, .zip, .sqlite, .pkl, or any file with a NUL byte in its first 8 KiB.
Common situations: Agent saves plots/screenshots or serialized artifacts in the sandbox and the UI tries to inline-preview them; CSV with embedded NULs from a bad export.
Related errors
- Invalid path
- Not found
- File too large
- This endpoint is not available
- No model provider is configured. Please configure at least o
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/318eae074eb0e22f.
Report an issue: GitHub.