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

member_list action returns deleted users #7170

Closed
avdata99 opened this issue Nov 2, 2022 · 2 comments · Fixed by #7493
Closed

member_list action returns deleted users #7170

avdata99 opened this issue Nov 2, 2022 · 2 comments · Fixed by #7493
Assignees

Comments

@avdata99
Copy link
Member

avdata99 commented Nov 2, 2022

CKAN version
2.9.7

Describe the bug
The member_list action with 'object_type': 'user' returns all member users, including deleted ones
This was fixed with #3078 but relies on the user_delete action.
If I manually delete a user from the DB, this will fail.

Steps to reproduce
Trying to iterate all members, you will get toolkit.ObjectNotFound for deleted users

 users = toolkit.get_action('member_list')(context, {
            'id': container['id'],
            'object_type': 'user',
        })
       
for user in users:
     duser = toolkit.get_action('user_show')(context, {'id': user[0]})

Expected behavior
member_list action must return only active users

Possible fix
Add an extra DB query to filter only active users

@amercader
Copy link
Member

To mimic the behaviour at the Python level introduced in #3078 (mark membership records as deleted when you delete a user via user_delete) we need to implement a foreign key with the proper CASCADE behaviour between the user and member tables.
Additionally we can add an extra check to the SQLAlchemy query in member_list that filters member records who don't have a record in the user table.
The same fix can probably be applied for datasets

@chetan-NEC
Copy link

@avdata99, @amercader I'm interested to work on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants