-
Notifications
You must be signed in to change notification settings - Fork 68
Add method to report fraud #2029
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
Conversation
| >>> deleted_count = project.delete_labels_by_user(user_id) | ||
| >>> print(f"Deleted {deleted_count} labels") | ||
| """ | ||
| labels_to_delete = list(self.labels(created_by=user_id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I assume in practice the list of ids is not too long; otherwise we should chunk it.
| ) | ||
| return len(labels) | ||
|
|
||
| def report_fraud( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, you might consider moving this logic to the server.
| len(labels), | ||
| self.project.uid | ||
| ) | ||
| return len(labels) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Label deletion missing chunking could overwhelm API
The _delete_user_labels method calls Entity.Label.bulk_delete(labels) without chunking, while the similar delete_labels_by_user method in project.py explicitly chunks at 500 with documentation stating this is "to avoid overwhelming the API". The report_fraud method uses the non-chunking version, which could fail when a fraudulent user has many labels—exactly the scenario where large label counts are likely.
Description
Adds a method to report potential fraud:
Fixes # (issue)
Type of change
Please delete options that are not relevant.
All Submissions
New Feature Submissions
Changes to Core Features
Note
Introduces a fraud-report flow that files a T&S case, removes a user from a project, and deletes their labels; adds
created_bylabel filtering and a client API to delete project memberships.AlignerrProject.report_fraud(user_id, reason, custom_metadata)orchestrates:_get_user_labels)_create_trust_safety_case)_remove_user_from_projectusing clientdelete_project_memberships)_delete_user_labels)Project.labels(..., created_by=...): add filter to query labels by creator (user ID orUser).Project.delete_labels_by_user(user_id): soft-delete labels for a user in chunks.Client.delete_project_memberships(project_id, user_ids): GraphQL mutation to remove users from a project.Written by Cursor Bugbot for commit 2ce41dc. This will update automatically on new commits. Configure here.