{"record":{"id":"9a282c417274f021","repo":"langflow-ai/langflow","slug":"content-type-not-found-for-extension-extension","errorCode":null,"errorMessage":"Content type not found for extension {extension}","messagePattern":"Content type not found for extension (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"src/backend/base/langflow/api/v1/files.py","lineNumber":143,"sourceCode":"@router.get(\"/download/{flow_id}/{file_name}\")\nasync def download_file(\n    file_name: ValidatedFileName,\n    flow: Annotated[Flow, Depends(get_flow)],\n    storage_service: Annotated[StorageService, Depends(get_storage_service)],\n):\n    # Authorization handled by get_flow dependency\n    flow_id_str = str(flow.id)\n    extension = file_name.split(\".\")[-1]\n\n    if not extension:\n        raise HTTPException(status_code=500, detail=f\"Extension not found for file {file_name}\")\n    try:\n        content_type = build_content_type_from_extension(extension)\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=str(e)) from e\n\n    if not content_type:\n        raise HTTPException(status_code=500, detail=f\"Content type not found for extension {extension}\")\n\n    try:\n        file_content = await storage_service.get_file(flow_id=flow_id_str, file_name=file_name)\n        headers = {\n            \"Content-Disposition\": build_content_disposition(file_name),\n            \"Content-Type\": \"application/octet-stream\",\n            \"Content-Length\": str(len(file_content)),\n        }\n        return StreamingResponse(BytesIO(file_content), media_type=content_type, headers=headers)\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=str(e)) from e\n\n\n@router.get(\"/images/{flow_id}/{file_name}\")\nasync def download_image(\n    file_name: ValidatedFileName,\n    # Security: resolve flow through get_flow so image access requires authentication and owner match.\n    flow: Annotated[Flow, Depends(get_flow)],","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/files.py#L125-L161","documentation":"HTTP 500 from GET /files/download/{flow_id}/{file_name} when build_content_type_from_extension returns a falsy value — the extension is syntactically fine but not present in the server's known extension→MIME map. The server refuses to guess a content type rather than defaulting, so the download cannot proceed.","triggerScenarios":"Downloading a file with an extension the server has no MIME mapping for (e.g. .foo, .custom, niche formats like .parquet on older builds); files created by components with nonstandard suffixes.","commonSituations":"Custom file artifacts produced by flow components; older Langflow builds with smaller MIME tables; users uploading then downloading proprietary-format files.","solutions":["Re-upload/store the file with a mapped extension (e.g. .bin or .txt) if the exact type doesn't matter","Upgrade langflow-base so the content-type table includes the extension","Patch build_content_type_from_extension's mapping to add the missing extension and restart"],"exampleFix":"# before\nGET /files/download/{flow_id}/run_42.parquet  # 500: content type not found\n\n# after\n# re-upload same bytes as run_42.bin, then\nGET /files/download/{flow_id}/2024-01-01_00-00-00_run_42.bin","handlingStrategy":"validation","validationCode":"KNOWN_EXTS = {\"txt\", \"pdf\", \"csv\", \"png\", \"jpg\", \"jpeg\", \"json\", \"zip\", \"bin\"}\n\ndef extension_supported(file_name: str) -> bool:\n    return file_name.rsplit(\".\", 1)[-1].lower() in KNOWN_EXTS","typeGuard":null,"tryCatchPattern":"try:\n    client.get(f\"/files/download/{flow_id}/{file_name}\").raise_for_status()\nexcept HTTPError as e:\n    if \"Content type not found\" in e.response.text:\n        client.get(f\"/files/download/{flow_id}/{renamed(file_name, '.bin')}\")","preventionTips":["Restrict uploads to extensions with known MIME mappings","Keep a client-side extension allow-list matched to the server's table"],"tags":["files","mime-type","download","http-500"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}