open-webui/backend/open_webui
Classic298 4f98a5184f
perf: resolve model-attached file access with a targeted query (#28802)
Checking whether a user may reach a file loaded and validated every workspace model that user can access, then scanned each model's knowledge list in Python for one file id. Folder listings run that check once per file, so opening a folder of twenty files rebuilt the whole accessible-model set twenty times, and the same check sits on every retrieval and download path.

The lookup now runs the other way round: the database returns the models that attach the file, and only those are access-checked. The text match on the metadata column is a prefilter and the knowledge entries still decide, so a file id that merely appears in a description grants nothing; file ids are server-generated uuids, so the match can only be too wide, never too narrow.

Measured with 500 accessible workspace models: a single check drops from 9 queries and ~20 ms to 6 and ~2.6 ms, and a twenty-file folder listing from 180 queries and ~680 ms to 120 and ~56 ms. A 72-case matrix over owner, public, direct-user and group grants, for both read and write, returns exactly what it returned before, and write still requires the model owner to own the file. The check also no longer writes to the database while answering a read-only question.
2026-08-19 11:07:43 -07:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal perf: route native JSON columns through JSONCodec instead of stdlib json (#28396) 2026-08-10 19:39:49 -05:00
migrations refac 2026-08-10 23:22:08 -06:00
models perf: resolve model-attached file access with a targeted query (#28802) 2026-08-19 11:07:43 -07:00
retrieval refac: issue Playwright web loader requests from the shared HTTP clients (#28634) 2026-08-17 01:06:12 -06:00
routers perf: stop scanning every skill on each listing and chat turn (#28798) 2026-08-19 11:07:33 -07:00
socket refac 2026-08-14 00:22:17 -06:00
static refac 2026-07-27 19:39:36 -04:00
storage refac 2026-07-31 17:41:14 -04:00
tools refac 2026-08-17 00:24:47 -07:00
utils perf: resolve model-attached file access with a targeted query (#28802) 2026-08-19 11:07:43 -07:00
__init__.py refac 2026-07-27 19:39:36 -04:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py refac 2026-08-17 00:47:32 -07:00
constants.py fix: reject COUNT rules without DTSTART so limited automations cannot run forever (#27781) 2026-08-12 01:08:55 -06:00
env.py fix: make the aiodns resolver opt-in and pin aiodns to 3.6.1 (#28242) 2026-08-10 19:52:29 -06:00
events.py refac 2026-08-16 23:21:00 -07:00
functions.py perf: build debug log messages lazily so disabled debug logs cost nothing (#27834) 2026-07-31 19:09:01 -05:00
main.py refac 2026-08-17 00:47:32 -07:00
tasks.py refac 2026-08-14 00:22:17 -06:00