Skip to content

Commit c83a421

Browse files
committed
refac
1 parent 2cacc2e commit c83a421

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

backend/open_webui/routers/retrieval.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2757,6 +2757,27 @@ async def process_files_batch(
27572757

27582758
for file in form_data.files:
27592759
try:
2760+
# Ownership check: verify the requesting user owns the file or is an admin
2761+
db_file = Files.get_file_by_id(file.id)
2762+
if not db_file:
2763+
file_errors.append(
2764+
BatchProcessFilesResult(
2765+
file_id=file.id,
2766+
status="failed",
2767+
error="File not found",
2768+
)
2769+
)
2770+
continue
2771+
if db_file.user_id != user.id and user.role != "admin":
2772+
file_errors.append(
2773+
BatchProcessFilesResult(
2774+
file_id=file.id,
2775+
status="failed",
2776+
error="Permission denied: not file owner",
2777+
)
2778+
)
2779+
continue
2780+
27602781
text_content = file.data.get("content", "")
27612782
docs: List[Document] = [
27622783
Document(

0 commit comments

Comments
 (0)