Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| knowledge_folder_model) | ||
| delete_auth(apps,application_folder_model) | ||
| delete_auth(apps,knowledge_folder_model) | ||
| delete_auth(apps,tool_folder_model) |
There was a problem hiding this comment.
There appears to be an inconsistency between how workspace_user_resource_permission_list is being generated using resource_model (which could refer to either "TOOL" or "KNOWLEDGE") and the subsequent call where it's deleted later (folder_model). This should ideally correspond to the same resource type.
Here’s a revised version of your function to address this issue:
def auth_folder(apps, schema_editor):
# Initialize an empty list for workspace user permissions
workspace_user_resource_permission_list = []
# Get permission lists using different types of resources (TOOL or KNOWLEDGE)
for resource_type in ["TOOL", "KNOWLEDGE"]:
resource_model_name = f"{resource_type}FolderModel"
folder_model = apps.get_model("yourappname", resource_model_name)
if not folder_model:
continue
workspace_user_role_mapping_model_workspace_dict = {
'WORKSPACE': {'id': 1},
'USER': {'id': 2}
}
workspace_user_resource_permission_list += get_workspace_user_resource_permission_list(
apps, resource_type,
workspace_user_role_mapping_model_workspace_dict,
folder_model
)
# Delete all permissions associated with each type of resource
for resource_type in ["TOOL", "KNOWLEDGE"]:
resource_model_name = f"{resource_type}FolderModel"
folder_model = apps.get_model("yourappname", resource_model_name)
if not folder_model:
continue
delete_auth(apps, folder_model)Key Points:
- Consistent Resource Model: Ensure that the model names match correctly when generating permission lists.
- Deletion Consistency: Verify that you are deleting models from the correct database table.
- Error Handling: Optional: Add error handling to manage cases where required models might not exist. For example, checking
if not folder_model:before proceeding can prevent errors related to non-existent tables.
This will ensure that authorization logic across your application maintains consistency regarding what types of resources are being operated on.
fix: Migrate file