Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Invalid attempt to access database with closed connection #1651

Merged
merged 5 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/1651.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move database accessing code to context manager scope
18 changes: 9 additions & 9 deletions src/ai/backend/manager/api/vfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2223,15 +2223,15 @@ async def _delete(
if not entry["is_owner"] and entry["permission"] != VFolderPermission.RW_DELETE:
raise InvalidAPIParameters("Cannot delete the vfolder that is not owned by myself.")
folder_host = entry["host"]
await ensure_host_permission_allowed(
conn,
folder_host,
allowed_vfolder_types=allowed_vfolder_types,
user_uuid=user_uuid,
resource_policy=resource_policy,
domain_name=domain_name,
permission=VFolderHostPermission.DELETE,
)
await ensure_host_permission_allowed(
conn,
folder_host,
allowed_vfolder_types=allowed_vfolder_types,
user_uuid=user_uuid,
resource_policy=resource_policy,
domain_name=domain_name,
permission=VFolderHostPermission.DELETE,
)

await update_vfolder_status(
root_ctx.db,
Expand Down
Loading