Conversation
mrobers1982
previously approved these changes
Dec 1, 2025
| >>> 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)) |
Contributor
There was a problem hiding this comment.
nit: I assume in practice the list of ids is not too long; otherwise we should chunk it.
| ) | ||
| return len(labels) | ||
|
|
||
| def report_fraud( |
Contributor
There was a problem hiding this comment.
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.
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.
Additional Locations (1)
mrobers1982
approved these changes
Dec 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.