Skip to content

[MNT] issue-assign-bot - only users with write access should be able to assign others #2739

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/utilities/issue_assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,22 @@
mentioned_users = [user[1:] for user in mentioned_users]
mentioned_users.remove("aeon-actions-bot")

# Get permissions of the commenter
commenter_permission = repo.get_collaborator_permission(commenter)

for user in mentioned_users:
if user != commenter and commenter_permission not in ["admin", "write"]:
comment_msg = (
f"@{commenter}, you cannot assign @{user}"
" because you lack write access.\n"
"Only users with write access can assign others."
)
issue.create_comment(comment_msg)
Comment on lines +44 to +50
Copy link
Member

Choose a reason for hiding this comment

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

I don't think a message should be written for each invalid user, just a single one for all.

Copy link
Contributor Author

@shinymack shinymack Apr 15, 2025

Choose a reason for hiding this comment

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

@MatthewMiddlehurst Should i use two arrays for valid and invalid users, then comment for the invalid users and then move onto the 2 issue limit code for valid users.
also the "assign me" statement doesn't check for the 2 issue limit, should i also fix that?
and for the code conflicting with the below one, do you mean that even when an admin is assigning someone it should check the 2 issue limit?

Copy link
Member

Choose a reason for hiding this comment

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

Just have a single printout if they try to assign someone else after the for loop. No need to @ them for each user they try to add.

If you continue the loop the code below wont run. there is lots of duplication going on im pretty sure

continue
elif user != commenter and commenter_permission in ["admin", "write"]:
issue.add_to_assignees(user)
continue
Comment on lines +52 to +54
Copy link
Member

Choose a reason for hiding this comment

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

this conflicts with the code below.


user_obj = g.get_user(user)
permission = repo.get_collaborator_permission(user_obj)

Expand Down