Regular expressions in Scarpet can return Java null
CommandLeo opened this issue ยท 4 comments
Set carpet superSecretSetting true
, try reproducing this again, then check the server log. Post the full exception here if avaliable.
In my opinion in this case it should return null
, to be consistent with the result of ''~'(.)'
java.lang.NullPointerException: Cannot invoke "String.trim()" because "in" is null
at Not Enough Crashes deobfuscated stack trace.(1.17.1+build.65) ~[?:?]
at jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1838) ~[?:?]
at jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110) ~[?:?]
at java.lang.Double.parseDouble(Double.java:651) ~[?:?]
at java.lang.Double.valueOf(Double.java:614) ~[?:?]
at carpet.script.value.Value.readDoubleNumber(Value.java:201) ~[fabric-carpet-1.18.2-1.4.69+v220331.jar:?]
at carpet.script.value.Value.readInteger(Value.java:211) ~[fabric-carpet-1.18.2-1.4.69+v220331.jar:?]
at carpet.commands.ScriptCommand.handleCall(ScriptCommand.java:453) ~[fabric-carpet-1.18.2-1.4.69+v220331.jar:?]
at carpet.commands.ScriptCommand.compute(ScriptCommand.java:505) ~[fabric-carpet-1.18.2-1.4.69+v220331.jar:?]
at carpet.commands.ScriptCommand.lambda$register$17(ScriptCommand.java:144) ~[fabric-carpet-1.18.2-1.4.69+v220331.jar:?]
at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:263) ~[brigadier-1.0.18.jar:?]
at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:177) ~[brigadier-1.0.18.jar:?]
at net.minecraft.server.command.CommandManager.execute(CommandManager:264) ~[?:?]
at net.minecraft.server.network.ServerPlayNetworkHandler.executeCommand(ServerPlayNetworkHandler:1253) ~[?:?]
at net.minecraft.server.network.ServerPlayNetworkHandler.handleMessage(ServerPlayNetworkHandler:1237) ~[?:?]
at net.minecraft.server.network.ServerPlayNetworkHandler.onGameMessage(ServerPlayNetworkHandler:1220) ~[?:?]
at net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket.apply(ChatMessageC2SPacket:30) ~[?:?]
at net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket.apply(ChatMessageC2SPacket:7) ~[?:?]
at net.minecraft.network.NetworkThreadUtils.method_11072(NetworkThreadUtils:22) ~[?:?]
at net.minecraft.server.ServerTask.run(ServerTask:18) ~[?:?]
at net.minecraft.util.thread.ThreadExecutor.executeTask(ThreadExecutor:157) ~[?:?]
at net.minecraft.util.thread.ReentrantThreadExecutor.executeTask(ReentrantThreadExecutor:23) ~[?:?]
at net.minecraft.server.MinecraftServer.executeTask(MinecraftServer:808) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.executeTask(MinecraftServer:165) ~[client-intermediary.jar:?]
at net.minecraft.util.thread.ThreadExecutor.runTask(ThreadExecutor:131) ~[?:?]
at net.minecraft.server.MinecraftServer.runOneTask(MinecraftServer:790) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.runTask(MinecraftServer:784) ~[client-intermediary.jar:?]
at net.minecraft.util.thread.ThreadExecutor.runTasks(ThreadExecutor:140) ~[?:?]
at net.minecraft.server.MinecraftServer.runTasksTillTickEnd(MinecraftServer:769) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.handler$zde000$modifiedRunLoop(MinecraftServer:2905) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer:676) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer:273) ~[client-intermediary.jar:?]
at java.lang.Thread.run(Thread.java:833) [?:?]
```
So I know where this happens, but I don't know what the correct behaviour would be given I don't know regex much.
Should this return an empty list, null
or a list with a null
element?
The scarpet docs specify the following:
null
if there is no match- matched phrase if no grouping is applied
- matched element if one group is applied
- list of matches if more than one grouping is applied
Now, from what I can get out of the javadocs for what scarpet uses, this match got 1 group (from the groupCount
call), but given null
is returned:
the match was successful but the group specified failed to match any part of the input sequence
Then the issue is carpet doesn't expect null
there, but a String
, and therefore it's introducing a broken value.
I think this should be scarpet null
from a quick look, though I'd prefer more opinions on this.
There also needs to be thought on what if there's multiple groups, because I'm quite sure if there's multiple groups matching this way scarpet will also also introduce broken values.