Skip to content

fix: Fix user cannot export public function lib#2394

Merged
liuruibin merged 1 commit intomainfrom
pr@main@fix_export_fun
Feb 25, 2025
Merged

fix: Fix user cannot export public function lib#2394
liuruibin merged 1 commit intomainfrom
pr@main@fix_export_fun

Conversation

@shaohuzhang1
Copy link
Contributor

fix: Fix user cannot export public function lib --bug=1052408 --user=刘瑞斌 【函数库】导出非当前用户创建的函数,报错 https://www.tapd.cn/57709429/s/1658696

--bug=1052408 --user=刘瑞斌 【函数库】导出非当前用户创建的函数,报错 https://www.tapd.cn/57709429/s/1658696
if not QuerySet(FunctionLib).filter(id=self.data.get('id')).exists():
raise AppApiException(500, _('Function does not exist'))

def delete(self, with_valid=True):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is an issue in the provided code. The filter method uses incorrect arguments in the second line of the function. It should be compared to all users' IDs (user_id__in=self.data.get('user_id', [])) instead of directly comparing the entire user object.

Here's the corrected version:

def delete(self, with_valid=True):

This change will fix the comparison logic so that it only deletes records where the ID matches exactly. Without knowing more about your application's database schema and how data types can vary, this adjustment assumes you want exact match checks which might not always be desirable depending on specific use cases or requirements.

If you need additional error handling or validation based on complex queries and relationships within FunctionLib, further refinement would be needed in these contexts.

@liuruibin liuruibin merged commit 666d586 into main Feb 25, 2025
4 checks passed
@liuruibin liuruibin deleted the pr@main@fix_export_fun branch February 25, 2025 07:59
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Feb 25, 2025

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.

Details

Instructions 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/test-infra repository.

1 similar comment
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Feb 25, 2025

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.

Details

Instructions 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/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants