Failing selectors and fake players in "score" selector result in an unexpected error
Trying to run a command that resolves a score text component results in "An unexpected error occurred trying to execute that command"
For example
tellraw @s {"score":{"name":"test","objective":"anything"}}
It breaks even the objective exists, and the score is assigned.
Using a selector in the name value instead of a fake player works ok
Environment
OS: Arch Linux
Java: Java 21.0.3
Linked Issues
Created Issue:
Commands result in an unexpected error with name based selector
Trying to run a command that resolves a text component results in "An unexpected error occurred trying to execute that command"
For example `/tellraw @s {"score":{"name":"name","objective":"anything"}}` and `/title @s title {"score":{"name":"name","objective":"anything"}}` break
It breaks even the objective exists, and the score is assigned.
Environment
OS: Arch Linux
Java: Java 21.0.3
Commandsresult in an unexpected errorwith name based selectorFake players in "score" selector result in an unexpected error
Trying to run a command that resolves a text component results in "An unexpected error occurred trying to execute that command"
For example `/tellraw @s {"score":{"name":"name","objective":"anything"}}` and `/title @s title {"score":{"name":"name","objective":"anything"}}` breakIt breaks even the objective exists, and the score is assigned.
Trying to run a command that resolves a text component results in "An unexpected error occurred trying to execute that command"
For example
tellraw @s {"score":{"name":"test","objective":"anything"}}It breaks even the objective exists, and the score is assigned.
Using a selector in the name value instead of a fake player works ok
Trying to run a command that resolves a text component results in "An unexpected error occurred trying to execute that command"
For example
tellraw @s {"score":{"name":"test","objective":"anything"}}It breaks even the objective exists, and the score is assigned.
Using a selector in the name value instead of a fake player works ok
Trying to run a command that resolves a text component results in "An unexpected error occurred trying to execute that command"
For example /tellraw @s {"score":{"name":"name","objective":"anything" and /title @s title {"score":{"name":"name","objective":"anything"}} break}}
It breaks even the objective exists, and the score is assigned.
Trying to run a command that resolves a text component results in "An unexpected error occurred trying to execute that command"
{{For example /tellraw @s {"score":{"name":"name","objective":"anything" and /title @s title {"score":{"name":"name","objective":"anything"}} break}}}}
It breaks even the objective exists, and the score is assigned.
Trying to run a command that resolves a text component results in "An unexpected error occurred trying to execute that command"
{{For example /tellraw @s {"score":{"name":"name","objective":"anything" and /title @s title {"score":{"name":"name","objective":"anything"}} break}}}}
It breaks even the objective exists, and the score is assigned.
Trying to run a command that resolves a score text component results in "An unexpected error occurred trying to execute that command"
For example
tellraw @s {"score":{"name":"test","objective":"anything"}}It breaks even the objective exists, and the score is assigned.
Using a selector in the name value instead of a fake player works ok
relates to
is duplicated by
relates to
Failing selectors and fake players in "score" selector result in an unexpected error
I think this duplicates MC-275297
Some behaviour to note:
This doesn't seem to occur on dedicated servers, maybe? (tested on a dedicated server ran with Java version 21.0.2).After some more testing, I think I found a more accurate description of the issue.
The error occurs if the name (A) looks like a selector (that is, a player name or @-selector), and (B) fails to find any results. So
I'll update the description again accordingly
From code analysis, the issue is evident. In findTargetName, previously if the selector found no results, the raw string name, which was still stored, was used to look up the score. However, with the refactor to use either, the raw string name is not present in this case, and so the fallthrough explicitly throws when trying to get it. It seems fitting for empty lists to either resolve to the empty string or throw the ERROR_NOT_SINGLE_ENTITY error instead, rather than the odd old behavior of attempting to look them up as fake players.