{"record":{"id":"693989be0fe53248","repo":"langflow-ai/langflow","slug":"str-e-693989","errorCode":null,"errorMessage":"str(e)","messagePattern":"str\\(e\\)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"src/backend/base/langflow/api/v1/files.py","lineNumber":105,"sourceCode":"    flow: Annotated[Flow, Depends(get_flow)],\n    current_user: CurrentActiveUser,\n    storage_service: Annotated[StorageService, Depends(get_storage_service)],\n    settings_service: Annotated[SettingsService, Depends(get_settings_service)],\n) -> UploadFileResponse:\n    # Writing a file to a flow's storage is a flow mutation: enforce WRITE so\n    # the external access ceiling (e.g. a \"viewer\") cannot upload via this route.\n    await ensure_flow_permission(\n        current_user,\n        FlowAction.WRITE,\n        flow_id=flow.id,\n        flow_user_id=flow.user_id,\n        workspace_id=flow.workspace_id,\n        folder_id=flow.folder_id,\n    )\n    try:\n        max_file_size_upload = settings_service.settings.max_file_size_upload\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=str(e)) from e\n\n    if file.size > max_file_size_upload * 1024 * 1024:\n        raise HTTPException(\n            status_code=413, detail=f\"File size is larger than the maximum file size {max_file_size_upload}MB.\"\n        )\n\n    # Authorization handled by get_flow dependency\n    try:\n        file_content = await file.read()\n        timestamp = datetime.now(tz=timezone.utc).astimezone().strftime(\"%Y-%m-%d_%H-%M-%S\")\n        file_name = file.filename or hashlib.sha256(file_content).hexdigest()\n        full_file_name = f\"{timestamp}_{file_name}\"\n        folder = str(flow.id)\n        await storage_service.save_file(flow_id=folder, file_name=full_file_name, data=file_content)\n        return UploadFileResponse(flow_id=str(flow.id), file_path=f\"{folder}/{full_file_name}\")\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=str(e)) from e\n","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/files.py#L87-L123","documentation":"In POST /files/upload/{flow_id}, reading settings_service.settings.max_file_size_upload is wrapped in try/except that converts any failure into HTTP 500 with the raw exception. This only fails if the settings service is broken (attribute missing after a version mismatch, corrupt settings file, service not initialized) — the attribute itself is a plain int in healthy deployments.","triggerScenarios":"Uploading a file while the settings service failed to load; running a backend where the settings schema lost max_file_size_upload (fork/version skew); corrupt config causing attribute access to raise.","commonSituations":"Pinned forks missing newer settings fields; partially upgraded installs; config dir unreadable so settings fell back to a broken object.","solutions":["Check the detail text for the AttributeError/settings error and fix the settings source (config dir, settings.json)","After upgrading Langflow, ensure backend package and settings schema are from the same version","Explicitly set LANGFLOW_MAX_FILE_SIZE_UPLOAD so the attribute resolves from env"],"exampleFix":"# before: settings.json from older version missing the key\n\n# after: force the value via env\nexport LANGFLOW_MAX_FILE_SIZE_UPLOAD=100","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    upload = client.post(f\"/files/upload/{flow_id}\", files=files)\nexcept HTTPError as e:\n    if e.response.status_code == 500 and \"max_file_size_upload\" in e.response.text:\n        alert_settings_schema_mismatch()\n    raise","preventionTips":["Keep langflow-base and settings file versions in lockstep in deployments","Set LANGFLOW_MAX_FILE_SIZE_UPLOAD explicitly to guarantee the attribute exists"],"tags":["files","settings","http-500","upload"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}