Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7869

Deserialized player head with long name crashes the client

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version dev-Spigot-5a6439b-8ee6fd1 (MC: 1.21.1) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
    • Yes

      Probably an issue since the 1.20.5 item component changes.

      Situation: A plugin loads a custom player head item that was created in earlier plugin versions. The item uses a name longer than 16 characters, which is no longer valid since 1.20.5.

      The item deserializes fine on the current server versions, but crashes the client once they open an inventory containing the item.

      [20:12:30] [Netty Server IO #0/ERROR]: Error sending packet clientbound/minecraft:merchant_offers
      io.netty.handler.codec.EncoderException: Failed to encode packet 'clientbound/minecraft:merchant_offers'
              at net.minecraft.network.codec.IdDispatchCodec.a(SourceFile:55) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.codec.IdDispatchCodec.encode(SourceFile:14) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.PacketEncoder.a(SourceFile:26) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.PacketEncoder.encode(SourceFile:12) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:107) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:113) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.ChannelOutboundHandlerAdapter.write(ChannelOutboundHandlerAdapter.java:113) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at net.minecraft.network.NetworkManager$2.write(NetworkManager.java:555) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:940) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:966) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:934) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:984) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1025) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:306) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at net.minecraft.network.NetworkManager.c(NetworkManager.java:374) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.NetworkManager.lambda$sendPacket$12(NetworkManager.java:367) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) ~[netty-common-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) ~[netty-common-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) ~[netty-common-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.97.Final.jar:4.1.97.Final]
              at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.97.Final.jar:4.1.97.Final]
              at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
      Caused by: io.netty.handler.codec.EncoderException: String too big (was 42 characters, max 16)
              at net.minecraft.network.Utf8String.a(SourceFile:38) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.codec.ByteBufCodecs$4.a(SourceFile:197) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.codec.ByteBufCodecs$4.encode(SourceFile:189) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.codec.ByteBufCodecs$10.a(SourceFile:335) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.codec.ByteBufCodecs$10.encode(SourceFile:322) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.codec.StreamCodec$13.encode(SourceFile:179) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.core.component.DataComponentPatch$1.a(DataComponentPatch.java:147) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.core.component.DataComponentPatch$1.a(DataComponentPatch.java:128) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.core.component.DataComponentPatch$1.encode(DataComponentPatch.java:66) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.world.item.ItemStack$1.a(ItemStack.java:191) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.world.item.ItemStack$1.encode(ItemStack.java:159) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.world.item.ItemStack$2.a(ItemStack.java:210) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.world.item.ItemStack$2.encode(ItemStack.java:195) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.world.item.trading.MerchantRecipe.a(MerchantRecipe.java:221) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.codec.StreamCodec$1.encode(SourceFile:25) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.codec.ByteBufCodecs$11.a(SourceFile:378) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.codec.ByteBufCodecs$11.encode(SourceFile:363) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.protocol.game.PacketPlayOutOpenWindowMerchant.a(SourceFile:39) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.codec.StreamCodec$6.encode(SourceFile:42) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.codec.StreamCodec$9.a(SourceFile:97) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.codec.StreamCodec$9.encode(SourceFile:87) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              at net.minecraft.network.codec.IdDispatchCodec.a(SourceFile:53) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:dev-Spigot-5a6439b-8ee6fd1]
              ... 31 more

      Item data inside the config:

      item:
              ==: org.bukkit.inventory.ItemStack
              v: 3955
              type: PLAYER_HEAD
              meta:
                ==: ItemMeta
                meta-type: SKULL
                skull-owner:
                  ==: PlayerProfile
                  uniqueId: 1b50b07b-acb3-4ad0-9762-68a71e9305e3
                  name: Some name longer than allowed by Minecraft
                  properties:
                  - name: textures
                    value: ewogICJ0aW1lc3RhbXAiIDogMTcxNjU1Nzk0NzkzMiwKICAicHJvZmlsZUlkIiA6ICJmYmFkNTg0ZmEyYTA0MjZhODZmMzgyMGFhZGEwOWVkZCIsCiAgInByb2ZpbGVOYW1lIiA6ICJTb2xpZFRvYXN0ZSIsCiAgInNpZ25hdHVyZVJlcXVpcmVkIiA6IHRydWUsCiAgInRleHR1cmVzIiA6IHsKICAgICJTS0lOIiA6IHsKICAgICAgInVybCIgOiAiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS85ZjEyNTNiNzUwZGMzMGQwMDY3Mzk5ZmRiOTMwYWQ3MTc4MWVmZmM4MjhlOTVhODlhNTNlYjVlNGE5MjNiZWRmIiwKICAgICAgIm1ldGFkYXRhIiA6IHsKICAgICAgICAibW9kZWwiIDogInNsaW0iCiAgICAgIH0KICAgIH0KICB9Cn0=

      It might make sense to either reject these items during deserialization or, similar to Minecraft's own migration, automatically clear or trim the now invalid profile names.

            Unassigned Unassigned
            blablubbabc blablubbabc
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: