{"record":{"id":"318eae074eb0e22f","repo":"langflow-ai/langflow","slug":"binary-content-not-supported","errorCode":null,"errorMessage":"Binary content not supported","messagePattern":"Binary content not supported","errorType":"http","errorClass":"HTTPException","httpStatus":415,"severity":"warning","filePath":"src/backend/base/langflow/agentic/api/files_router.py","lineNumber":175,"sourceCode":"            resolved.exists(),\n            resolved.is_dir(),\n        )\n        raise HTTPException(status_code=404, detail=\"Not found\")\n\n    try:\n        size = resolved.stat().st_size\n    except OSError:\n        raise HTTPException(status_code=404, detail=\"Not found\") from None\n    if size > MAX_FILE_SIZE_BYTES:\n        raise HTTPException(status_code=413, detail=\"File too large\")\n\n    # Binary sniff before the full read — same heuristic the FS tool uses.\n    try:\n        head = _read_head_no_follow(resolved, BINARY_SNIFF_BYTES)\n    except (OSError, PermissionError):\n        raise HTTPException(status_code=404, detail=\"Not found\") from None\n    if _looks_binary(head):\n        raise HTTPException(status_code=415, detail=\"Binary content not supported\")\n\n    try:\n        body_bytes = _read_bytes_no_follow(resolved)\n    except (OSError, PermissionError):\n        raise HTTPException(status_code=404, detail=\"Not found\") from None\n\n    # Audit log — relative path only, never the absolute sandbox-resolved path.\n    logger.info(\n        \"agentic.files.read user_id=%s path=%s size=%d download=%s\",\n        current_user.id,\n        path,\n        len(body_bytes),\n        download,\n    )\n\n    if download:\n        filename = _safe_filename_for_disposition(path) or \"file\"\n        return Response(","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/agentic/api/files_router.py#L157-L193","documentation":"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.","triggerScenarios":"GET /api/v1/agentic/files on a .png, .zip, .sqlite, .pkl, or any file with a NUL byte in its first 8 KiB.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"SNIFF = 8192\nwith open(sandbox_path, \"rb\") as f:\n    looks_binary = b\"\\x00\" in f.read(SNIFF)\nif looks_binary:\n    use_download_flow(sandbox_path)","typeGuard":null,"tryCatchPattern":"if resp.status_code == 415:\n    switch_to_binary_transfer(path)  # sniff is deterministic; retries are useless","preventionTips":["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."],"tags":["agentic","files","http-415","binary","content-type"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}