fix(BA-2832): Seperate permission group DTOs based on whether relationship data load is needed#6415
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors permission group DTOs to separate concerns between basic data transfer and extended data that includes relationship data. The change introduces PermissionGroupExtendedData as a new DTO that includes nested permissions, while keeping PermissionGroupData as a lighter-weight alternative without relationships. This separation prevents lazy loading errors by making relationship data requirements explicit at the type level.
Key changes:
- Introduced
PermissionGroupExtendedDataDTO to include nested permissions data - Updated
RoleDataWithPermissionsto usePermissionGroupExtendedDatainstead ofPermissionGroupData - Added
to_extended_data()method toPermissionGroupRowmodel for converting to the extended DTO
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/ai/backend/manager/data/permission/permission_group.py | Adds new PermissionGroupExtendedData dataclass with permissions field |
| src/ai/backend/manager/models/rbac_models/permission/permission_group.py | Implements to_extended_data() method and imports new DTO |
| src/ai/backend/manager/data/permission/role.py | Updates import and type annotation to use PermissionGroupExtendedData |
| src/ai/backend/manager/models/rbac_models/role.py | Changes method call from to_data() to to_extended_data() |
| changes/6451.enhance.md | Documents the enhancement |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fregataa
left a comment
There was a problem hiding this comment.
Good. How about setting PR prefix as fix rather than refactor?
…nship data load is needed (#6415)
resolves #6414 (BA-2832)
Checklist: (if applicable)
ai.backend.testdocsdirectory