Repository navigation
fix(command): handle accounts without an email in /authme email - #3162
Merged
Merged
Conversation
GetEmailCommand passed the stored email straight to the admin.email_show message. For an account that has no email the value is null, so Messages.retrieveSingle threw a NullPointerException and the sender only got "An unexpected error occurred". Check the value with Utils.isEmailEmpty, as /email show does, and send the existing email.no_email_for_account message in that case. Fixes AuthMe#3091
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.
/authme email <player>throws when the account exists but has no email, as in the stack trace in #3091.GetEmailCommandpassesemail.getValue()straight to theadmin.email_showmessage; the value is null for such an account andMessages.retrieveSinglefails inString.replacewith"replacement" is null. The sender only gets "An unexpected error occurred trying to execute that command".The command now checks the value with
Utils.isEmailEmpty, the same check/email showuses, and sends the existingemail.no_email_for_accountmessage. I reused that message to avoid a new key in every language file. Its wording is addressed to the player ("You currently don't have email address associated with this account."), so tell me if you would rather have a separate admin message and I will add one.Testing:
GetEmailCommandTest.shouldReportMissingEmail; it fails on master and passes with the change.mvn -V -B clean packageon JDK 21 (all modules) and JDK 17: build passes, 1445 tests in authme-core.PurgeServiceTest.shouldRunAutoPurgefailed once on a loaded machine (124 ms against its 100 ms tolerance) and passed on the rerun; it is unrelated.AuthMe-*-Paper.jar: on masterauthme email <name>from the console logs the NPE from the issue for an account without an email; with the change it prints the message. Same result for an op player running/authme emailin game. An account with an email still prints<name>'s email: ..., and an unknown name still prints "This user isn't registered!".Not tested: MySQL and PostgreSQL.
Fixes #3091