[PR #23111] [CLOSED] fix: handle None meta in FileMeta.sanitize_meta() to prevent API 500 errors #27035

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

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/23111
Author: @yang1002378395-cmyk
Created: 3/26/2026
Status: Closed

Base: devHead: fix/files-api-500-null-meta-v2


📝 Commits (1)

  • bfe164e fix: handle None meta in FileMeta.sanitize_meta() to prevent API 500 error

📊 Changes

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

View changed files

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

📄 Description

Pull Request Checklist

  • Target branch: dev
  • Description: Fix regression in v0.8.11 where /api/v1/files/ returns HTTP 500 when database contains NULL meta values
  • Changelog: Added below
  • Testing: Manually verified the fix by analyzing the code path and confirming the root cause

Changelog Entry

Description

  • Fix regression in v0.8.11 where /api/v1/files/ returns HTTP 500 Internal Server Error

Fixed

  • FileMeta.sanitize_meta() now returns empty dict {} instead of None for non-dict input, preventing Pydantic ValidationError when FileModelResponse.meta is required

Root Cause Analysis

In v0.8.11, FileListResponse.items changed from list[FileModel] to list[FileModelResponse]. FileModelResponse.meta is a required field (not Optional), but sanitize_meta() was returning None unchanged when the database value was NULL. This caused Pydantic v2 to raise ValidationError → HTTP 500.

Test Plan

  1. Create files with NULL meta in database (legacy data)
  2. Call GET /api/v1/files/
  3. Expected: 200 with empty meta objects
  4. Before fix: 500 Internal Server Error

Fixes #23101


Contributor License Agreement


🔄 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/23111 **Author:** [@yang1002378395-cmyk](https://github.com/yang1002378395-cmyk) **Created:** 3/26/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/files-api-500-null-meta-v2` --- ### 📝 Commits (1) - [`bfe164e`](https://github.com/open-webui/open-webui/commit/bfe164ee4b0ddb610be00dc1288c0d85ba31afa5) fix: handle None meta in FileMeta.sanitize_meta() to prevent API 500 error ### 📊 Changes **1 file changed** (+2 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/models/files.py` (+2 -1) </details> ### 📄 Description # Pull Request Checklist - [x] **Target branch:** dev - [x] **Description:** Fix regression in v0.8.11 where /api/v1/files/ returns HTTP 500 when database contains NULL meta values - [x] **Changelog:** Added below - [x] **Testing:** Manually verified the fix by analyzing the code path and confirming the root cause # Changelog Entry ### Description - Fix regression in v0.8.11 where /api/v1/files/ returns HTTP 500 Internal Server Error ### Fixed - FileMeta.sanitize_meta() now returns empty dict {} instead of None for non-dict input, preventing Pydantic ValidationError when FileModelResponse.meta is required ### Root Cause Analysis In v0.8.11, FileListResponse.items changed from list[FileModel] to list[FileModelResponse]. FileModelResponse.meta is a required field (not Optional), but sanitize_meta() was returning None unchanged when the database value was NULL. This caused Pydantic v2 to raise ValidationError → HTTP 500. ### Test Plan 1. Create files with NULL meta in database (legacy data) 2. Call GET /api/v1/files/ 3. Expected: 200 with empty meta objects 4. Before fix: 500 Internal Server Error Fixes #23101 --- ### Contributor License Agreement - [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <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:49:53 -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#27035