Skip to content

Commit f0e0cfc

Browse files
Classic298claude
andauthored
perf: avoid redundant knowledge re-fetch in update_knowledge_access_by_id (open-webui#23799)
After set_access_grants, the handler was reloading the same knowledge record via get_knowledge_by_id, which triggers an extra SELECT plus a nested fetch of access grants. set_access_grants already returns the newly-written grants and the local knowledge object is otherwise unchanged, so update it in place and reuse it for the response. https://claude.ai/code/session_01S18Lgqbih7Ry2JZUUv8TxF Co-authored-by: Claude <noreply@anthropic.com>
1 parent 55bfc7c commit f0e0cfc

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

backend/open_webui/routers/knowledge.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,12 @@ async def update_knowledge_access_by_id(
539539
'sharing.public_knowledge',
540540
)
541541

542-
await AccessGrants.set_access_grants('knowledge', id, form_data.access_grants, db=db)
542+
knowledge.access_grants = await AccessGrants.set_access_grants(
543+
'knowledge', id, form_data.access_grants, db=db
544+
)
543545

544546
return KnowledgeFilesResponse(
545-
**(await Knowledges.get_knowledge_by_id(id=id, db=db)).model_dump(),
547+
**knowledge.model_dump(),
546548
files=await Knowledges.get_file_metadatas_by_id(id, db=db),
547549
)
548550

0 commit comments

Comments
 (0)