Endpoint user preview ignores owned knowledge bases in items list #27407
Marius-brt
started this conversation in
Issues
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
While working on
GET /api/v1/users/{user_id}/preview, I noticed a bug where knowledge bases created directly by a user do not show up in their preview items list.Problem
The endpoint returns an empty
knowledge.itemsarray for knowledge bases owned by the target user (knowledge.user_id == user_id), even thoughknowledge.totalcounts them.Root cause:
The endpoint evaluates access exclusively via
AccessGrants.get_accessible_resource_ids. Because resource ownership (knowledge.user_id) is stored separately from theaccess_grantstable, owned items are filtered out.This logic is already properly handled elsewhere in the codebase (e.g.,
Knowledges.get_knowledge_bases_by_user_id), where it explicitly checksknowledge_base.user_id == user_idbefore falling back toAccessGrants.has_access.Proposed Fix
In
backend/open_webui/routers/users.py, update the list comprehension to account for implicit owner access:Key Takeaways
user_idis already in scope andall_knowledgeis already queried.modelsandtoolsin the same endpoint rely on the same check, but knowledge bases are the primary resource affected by direct user ownership.I have a PR ready for this fix and can submit it right away if approved!
All reactions