[PR #22426] [CLOSED] fix: use correct attribute file.data instead of file.content in file download #26683

Closed
opened 2026-04-20 06:38:55 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22426
Author: @gambletan
Created: 3/8/2026
Status: Closed

Base: mainHead: fix/file-content-attribute-error


📝 Commits (1)

  • 264f828 fix: use correct attribute file.data instead of file.content

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 backend/open_webui/routers/files.py (+1 -1)

📄 Description

Summary

In the GET /{id}/content/{file_name} endpoint, when a file has no storage path and the code falls back to returning file content inline, it accesses file.content.get("content", ""). However, FileModel has no content attribute — the correct attribute is data (which is Optional[dict]).

This causes an AttributeError: 'FileModel' object has no attribute 'content' crash at runtime whenever this fallback path is hit.

Fix

  • Changed file.content.get(...) to file.data.get(...)
  • Added a None guard since data is Optional[dict]

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/22426 **Author:** [@gambletan](https://github.com/gambletan) **Created:** 3/8/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/file-content-attribute-error` --- ### 📝 Commits (1) - [`264f828`](https://github.com/open-webui/open-webui/commit/264f8282f9cd09da84e58cd1984ba3b096d1d7f9) fix: use correct attribute `file.data` instead of `file.content` ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/files.py` (+1 -1) </details> ### 📄 Description ## Summary In the `GET /{id}/content/{file_name}` endpoint, when a file has no storage path and the code falls back to returning file content inline, it accesses `file.content.get("content", "")`. However, `FileModel` has no `content` attribute — the correct attribute is `data` (which is `Optional[dict]`). This causes an `AttributeError: 'FileModel' object has no attribute 'content'` crash at runtime whenever this fallback path is hit. ### Fix - Changed `file.content.get(...)` to `file.data.get(...)` - Added a `None` guard since `data` is `Optional[dict]` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 06:38:55 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#26683