mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[GH-ISSUE #10342] bug: Including file_metadata in /files/ route not working #15861
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @almajo on GitHub (Feb 19, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/10342
Bug Report
Environment
Confirmation:
Expected Behavior:
Since one of the last versions, 'file_metadata' was added to the /files POST route when uploading files. When adding a dictionary, I want this to be added within
metaof the file.Actual Behavior:
When calling the API (even through the Swagger UI), the API returns a 422 Error: Uprocessable Entity
Description
Bug Summary:
Either through python requests or CURL, I can't get it working.
Through the UI I send the following request:
and receive this response:
with headers
I also played around sending the request through request where I tried adding the metadata to json or data argument. Same results.
Sending no metadata works to upload the file
Reproduction Details
Steps to Reproduce:
Super simple. Open Swagger UI on /docs and send a POST request to /api/v1/files/ with an uploaded file and include metadata.
@tjbck commented on GitHub (Feb 19, 2025):
file_metadatais not intended to be accessible by API.@almajo commented on GitHub (Feb 19, 2025):
Hi @tjbck, why not?
When adding a file through an external script,I would like to have some metadata (custom urls, titles, user restrictions, ...) in order to use this later for knowledge retrieval and citations. That would be a great benefit.
Even if it's not intended, do you know a way how to use it anyway through API?
@kaytwo commented on GitHub (Mar 24, 2025):
I just ran into this as well - same need, pity it won't be supported. My read of how
b03fc97e28/backend/open_webui/routers/files.py (L36)works is that there's no way to successfully upload file_metadata as is, I can't seem to get the pydantic model to validate the input dictionary, it would probably need a fix like https://stackoverflow.com/questions/63110848/how-do-i-send-list-of-dictionary-as-body-parameter-together-with-files-in-fastap to work properly.For what it's worth, my workaround is to put whatever metadata is relevant in the body of the file itself, as there isn't currently any performance gain to be had by accessing just metadata vs. all of the file's data all at once (the api only ever gives you the metadata+data afaict).
@HyuPete commented on GitHub (May 7, 2025):
My workaround is to make some small changes to
backend/open_webui/routers/files.pylike in the attached image. Comments are welcome.