-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix errors and bugs in RevokePriorityModule #768
base: master
Are you sure you want to change the base?
Conversation
} | ||
|
||
private fun isValidPriority(priority: String): Boolean = | ||
setOf("-1", "11700", "11701", "11702", "11703").contains(priority) |
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.
To avoid duplication, what about having a map from priority name to ID, which is then used by getId
, and isValidPriority
could use the values of the map instead.
val originalPriorityName = originalPriorityItem?.changedToString.getOrDefaultNull("None") | ||
|
||
// Check whether the original priority differs from the current priority | ||
assertNotEquals(getId(priority), originalPriorityId).bind() |
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.
I am a bit worried what happens when a new priority is added, and when a Mojang employee then changes the priority of an issue (which is not "None") to that new priority. To me it looks like this assertion here would erroneously consider them unequal because getId
would return "-1"
, even though the new priority is the same set by originalPriorityItem
.
Is there a way to obtain the priority ID from the issue? If not, would one of these implementations make sense?
- compare priority names instead (or maybe only as fallback if the ID for the priority cannot be determined)
- change
getId
to returnString?
and don't try to revert the priority change if the result ofgetId
for the new priority isnull
- check the changelog to verify that the last change was not done by a staff member (might be error-prone?)
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 theory, in this case, priority
should always be equal to originalPriority
, since that's both the most recent staff priority changelog item and the current priority of the issue.
Aka, priority
is always the already updated priority, not the priority from before the change. Which is what makes things tricky.
E.g. Mojang developer changes priority from None to Normal:
priority
is now11702
originalPriorityItem
is `None [-1] -> Normal [11702]originalPriorityId
is11702
Thus this check would fail and the module would return OperationNotNeeded.
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.
The case I was thinking of is:
A new priority "Extremely Important" with ID 11699 is added, and a Mojang developer changes the priority of an issue to "Extremely Important". originalPriorityId
is therefore "11699"
and priority
is "Extremely Important"
. However, because getId
does not know the ID for "Extremely Important", it returns "-1"
, which is unequal to "11699"
, and therefore the module erroneously reverts the change.
Or am I misunderstanding something here?
Purpose
This addresses multiple issues with the RevokePriorityModule:
Approach
Added more checks:
In this case I'm not sure if it even makes sense to still have the
updateIsRecent
check there. Since the changelog is messed up for mojang priority I don't see any other way though without it getting more involved.Future work
Perhaps we should disable this module and only enable it when it is needed?
Checklist
docs
folder