Skip to content

fix: Scope group vfolders by group_id in the REST folder list#12367

Draft
rapsealk wants to merge 3 commits into
mainfrom
fix/folders-honor-group-id
Draft

fix: Scope group vfolders by group_id in the REST folder list#12367
rapsealk wants to merge 3 commits into
mainfrom
fix/folders-honor-group-id

Conversation

@rapsealk

Copy link
Copy Markdown
Member

Summary

GET /folders (the vfolder list REST API) accepts a group_id query parameter
and the handler resolves it into a PROJECT scope, but VFolderService.list
never used the scope: it called list_accessible_vfolders without it and only
echoed _scope_type/_scope_id back in the result. So the listing always
returned the full accessible union — every MODEL_STORE project, plus every
domain project for admins, and all group vfolders for superadmins — regardless
of the requested scope. group_id was a silent no-op.

Verified on 26.4.4: /folders == /folders?group_id=<project> for both a
superadmin and a regular user.

Change

Thread a group_scope_id through VFolderRepository.list_accessible_vfolders
into query_accessible_vfolders as extra_vf_group_conds (group == scope_id),
applied only when the request is project-scoped:

  • User-owned and invited vfolders are unaffected.
  • A project-scoped request now returns the caller's own folders plus only that
    project's group folders
    — matching the vfolder_nodes GraphQL connection
    (scope_id: "project:<id>"), which already scopes correctly and is what the
    WebUI uses.
  • A request without group_id (USER scope) is unchanged — back-compatible.

Tests

tests/unit/manager/services/vfolder/test_vfolder_crud_service.py:

  • test_project_scope_restricts_group_vfolders — PROJECT scope forwards
    group_scope_id.
  • test_user_scope_does_not_restrict_group_vfolders — USER scope forwards
    None.

Both pass via pants test. ruff/pants fmt clean.

Fixes #12363.

Copilot AI review requested due to automatic review settings June 23, 2026 05:02
@rapsealk rapsealk requested a review from a team as a code owner June 23, 2026 05:02
@rapsealk rapsealk added this to the 26.4 milestone Jun 23, 2026
@github-actions github-actions Bot added the size:M 30~100 LoC label Jun 23, 2026
@github-actions github-actions Bot added the comp:manager Related to Manager component label Jun 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the REST vfolder listing behavior so that GET /folders?group_id=<project_uuid> actually scopes group-owned vfolders to the requested project, instead of always returning the full “accessible union” regardless of scope. The change aligns REST behavior with the already-correctly-scoped GraphQL vfolder_nodes behavior described in the linked issue.

Changes:

  • Apply a project-scope filter in VFolderService.list() by forwarding a group_scope_id when the action is ScopeType.PROJECT.
  • Thread group_scope_id through VfolderRepository.list_accessible_vfolders() into query_accessible_vfolders() via extra_vf_group_conds.
  • Add unit tests to ensure group_scope_id is forwarded for PROJECT scope and omitted for USER scope, plus a Towncrier fragment.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/ai/backend/manager/services/vfolder/services/vfolder.py Derives group_scope_id for PROJECT scope and forwards it to the repository to enforce project scoping for group vfolders.
src/ai/backend/manager/repositories/vfolder/repository.py Adds group_scope_id parameter and translates it into extra_vf_group_conds for the underlying accessible-vfolders query.
tests/unit/manager/services/vfolder/test_vfolder_crud_service.py Adds unit tests verifying the service forwards group_scope_id only for PROJECT scope.
changes/12363.fix.md Documents the bugfix for release notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

`GET /folders` accepts a `group_id` query parameter and the handler resolves it
into a PROJECT scope, but `VFolderService.list` ignored the scope — it called
`list_accessible_vfolders` without it and only echoed `_scope_type`/`_scope_id`
back in the result. So the listing always returned the full accessible union
(every MODEL_STORE project, plus every domain project for admins), making
`group_id` a silent no-op.

Thread a `group_scope_id` through `VFolderRepository.list_accessible_vfolders`
into `query_accessible_vfolders` as `extra_vf_group_conds` (group == scope_id),
applied only when the request is project-scoped. User-owned and invited vfolders
are unaffected, so a project-scoped request returns the caller's own folders plus
that project's group folders — matching the `vfolder_nodes` GraphQL connection.

Fixes #12363.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rapsealk rapsealk changed the title fix(manager): scope group vfolders by group_id in the REST folder list fix: Scope group vfolders by group_id in the REST folder list Jun 23, 2026
@rapsealk rapsealk force-pushed the fix/folders-honor-group-id branch from 6fa1491 to d4aafd7 Compare June 23, 2026 07:24
12363.fix.md -> 12367.fix.md

Co-authored-by: octodog <mu001@lablup.com>
Comment thread src/ai/backend/manager/repositories/vfolder/repository.py Outdated
Comment thread src/ai/backend/manager/services/vfolder/services/vfolder.py Outdated
Per review feedback: prefer "project" over "group" for the scope argument, and
`project_id` is sufficient (no `_scope_` suffix needed). Renames the new
`group_scope_id` parameter on `VFolderService.list` /
`VFolderRepository.list_accessible_vfolders` to `project_id`, matching the
`project_id` naming already used elsewhere in the vfolder tests. The underlying
`VFolderRow.group` column and the REST `group_id` query parameter are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rapsealk rapsealk requested a review from seedspirit June 23, 2026 08:09
@rapsealk rapsealk marked this pull request as draft June 24, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:manager Related to Manager component size:M 30~100 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REST GET /folders silently ignores group_id (scope not applied in VFolderService.list)

3 participants