Spongeapi: Passing invalid username to optional user arg causes error while parsing command

Created on 3 Apr 2018  路  4Comments  路  Source: SpongePowered/SpongeAPI

Somewhere between SpongeForge 2990 and 2996, this code:

    private static final CommandElement TARGET_ELEMENT = firstParsing(
        user(Text.of("user")),
        string(Text.of("address"))
    );

no longer works as it should.

Before updating Sponge

/pay Lemmmy - works properly. user arg is set.
/pay foo@bar - works properly. address arg is set.

After updating Sponge

/pay Lemmmy - works properly. user arg is set.
/pay foo@bar - errors - says Error occured while executing command: Invalid username foo@bar to the user, and logs this exception to the console.

This does not seem like intended behaviour for firstParsing.

7 command bug

All 4 comments

Yep, that needs to be wrapped up in an ArgumentParseException.

Or maybe not throw exceptions when getting a user by invalid name?
We have Optional.empty.

@Faithcaio it used to return Optional.empty(); I believe a recent commit changed this behaviour (possibly accidentally).

Yeah, it's accidental. It's because I try to get an exact match before doing pattern matching to improve performance. I'm working on it now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rodel77 picture rodel77  路  6Comments

Lergin picture Lergin  路  5Comments

Cybermaxke picture Cybermaxke  路  6Comments

lesbleu picture lesbleu  路  4Comments

mbax picture mbax  路  3Comments