Curios API (Forge/NeoForge)

Curios API (Forge/NeoForge)

140M Downloads

[1.19.x+?] Partially enforced 25-character limit on `ICuriosItemHandler::getCurios` `Map` keys

noobanidus opened this issue ยท 3 comments

commented

A user of Lootr is somehow running into this issue when they change their configuration away from default; I assume that some other mod (in their 1.19.2 mod pack) is adding compatibility with Curios.

With the assistance of Spit It Out, they managed to extract this error message:

[00:49:39] [Netty Local Client IO #0/WARN]: An exception 'java.lang.NullPointerException: Cannot invoke "java.lang.Throwable.printStackTrace(java.io.PrintStream)" because "cause" is null' [enable DEBUG level for full stacktrace] was thrown by a user handler's exceptionCaught() method while handling the following exception:
io.netty.handler.codec.DecoderException: The received string length is longer than maximum allowed (27 > 25)
	at net.minecraft.network.FriendlyByteBuf.m_130136_(FriendlyByteBuf.java:574) ~[client-1.19.2-20220805.130853-srg.jar%23783!/:?]
	at top.theillusivec4.curios.common.network.server.sync.SPacketSyncCurios.decode(SPacketSyncCurios.java:75) ~[curios-forge-1.19.2-5.1.4.1.jar%23573!/:1.19.2-5.1.4.1]
	at net.minecraftforge.network.simple.IndexedMessageCodec.lambda$tryDecode$0(IndexedMessageCodec.java:107) ~[forge-1.19.2-43.3.0-universal.jar%23788!/:?]
	at java.util.Optional.map(Optional.java:260) ~[?:?]
	at net.minecraftforge.network.simple.IndexedMessageCodec.tryDecode(IndexedMessageCodec.java:107) ~[forge-1.19.2-43.3.0-universal.jar%23788!/:?]
	at net.minecraftforge.network.simple.IndexedMessageCodec.consume(IndexedMessageCodec.java:153) ~[forge-1.19.2-43.3.0-universal.jar%23788!/:?]
	at net.minecraftforge.network.simple.SimpleChannel.networkEventListener(SimpleChannel.java:63) ~[forge-1.19.2-43.3.0-universal.jar%23788!/:?]
	at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:260) ~[eventbus-6.0.3.jar%2385!/:?]
	at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:252) ~[eventbus-6.0.3.jar%2385!/:?]
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.3.jar%2385!/:?]
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.3.jar%2385!/:?]
	at net.minecraftforge.network.NetworkInstance.dispatch(NetworkInstance.java:68) ~[forge-1.19.2-43.3.0-universal.jar%23788!/:?]
	at net.minecraftforge.network.NetworkHooks.lambda$onCustomPayload$1(NetworkHooks.java:77) ~[forge-1.19.2-43.3.0-universal.jar%23788!/:?]
	at java.util.Optional.map(Optional.java:260) ~[?:?]
	at net.minecraftforge.network.NetworkHooks.onCustomPayload(NetworkHooks.java:77) ~[forge-1.19.2-43.3.0-universal.jar%23788!/:?]
	at net.minecraft.client.multiplayer.ClientPacketListener.m_7413_(ClientPacketListener.java:1674) ~[client-1.19.2-20220805.130853-srg.jar%23783!/:?]
	at net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket.m_5797_(ClientboundCustomPayloadPacket.java:57) ~[client-1.19.2-20220805.130853-srg.jar%23783!/:?]
	at net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket.m_5797_(ClientboundCustomPayloadPacket.java:7) ~[client-1.19.2-20220805.130853-srg.jar%23783!/:?]
	at net.minecraft.network.Connection.m_129517_(Connection.java:163) ~[client-1.19.2-20220805.130853-srg.jar%23783!/:?]
	at net.minecraft.network.Connection.channelRead0(Connection.java:148) ~[client-1.19.2-20220805.130853-srg.jar%23783!/:?]
	at net.minecraft.network.Connection.channelRead0(Connection.java:48) ~[client-1.19.2-20220805.130853-srg.jar%23783!/:?]
	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) ~[netty-transport-4.1.77.Final.jar%23117!/:4.1.77.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.77.Final.jar%23117!/:4.1.77.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.77.Final.jar%23117!/:4.1.77.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.77.Final.jar%23117!/:4.1.77.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [netty-transport-4.1.77.Final.jar%23117!/:4.1.77.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.77.Final.jar%23117!/:4.1.77.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.77.Final.jar%23117!/:4.1.77.Final]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [netty-transport-4.1.77.Final.jar%23117!/:4.1.77.Final]
	at io.netty.channel.local.LocalChannel.readInbound(LocalChannel.java:299) [netty-transport-4.1.77.Final.jar%23117!/:4.1.77.Final]
	at io.netty.channel.local.LocalChannel.finishPeerRead0(LocalChannel.java:445) [netty-transport-4.1.77.Final.jar%23117!/:4.1.77.Final]
	at io.netty.channel.local.LocalChannel.access$400(LocalChannel.java:50) [netty-transport-4.1.77.Final.jar%23117!/:4.1.77.Final]
	at io.netty.channel.local.LocalChannel$5.run(LocalChannel.java:403) [netty-transport-4.1.77.Final.jar%23117!/:4.1.77.Final]
	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) [netty-common-4.1.77.Final.jar%23112!/:4.1.77.Final]
	at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) [netty-transport-4.1.77.Final.jar%23117!/:4.1.77.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:995) [netty-common-4.1.77.Final.jar%23112!/:4.1.77.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.77.Final.jar%23112!/:4.1.77.Final]
	at java.lang.Thread.run(Thread.java:833) [?:?]

This appears to be related to SPacketSyncCurios::78 which specifically reads a 25-long UTF string.

However, the previous encode function just writes the key regardless.

This is an issue when mods (specifically Create Goggle) use IMC and pass a key that is longer than 25 characters. Specifically this can be found in their use of IMC to create a slot called creategoggles.backtank_slot.

This is probably not a common issue as 25 characters is likely not exceeded, and when it is exceeded, no error is actually logged but instead an encoding error with the "got 27, expected 25" error message is displayed, hence why it may not have been reported to you earlier.

While I have specifically flagged this as being for 1.19.2 (as this is where the user encountered the issue and can replicate it), this appears to go as far back as at least 1.16.x for Forge, and extends into 1.20.x, etc.

commented

What happens when this error occurs? Does it crash, or is it like an error screen appears?

commented

It displays one of those "connection error" screens then drops back to the multiplayer connect window:

commented

Ah I see, understood. Thanks for reporting this issue, this could've gone undetected for a lot longer. It's at least an easy fix so I'll get working on releasing the necessary updates across affected versions.