Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-121806

JSON text component parser throws unhandled exceptions when incorrect data type was provided

XMLWordPrintable

    • Confirmed

      The bug

      The JSON text component parser throws unhandled exceptions when data of an incorrect type was provided. For example:

      • "text":[]
      • "text":"","extra":1

      When using this while typing in chat the client crashes with the description keyPressed event handler, in command blocks the exception is written to the log.

      Description: charTyped event handler
      
      java.lang.ClassCastException: com.google.gson.JsonPrimitive cannot be cast to com.google.gson.JsonObject
      	at com.google.gson.JsonObject.getAsJsonObject(JsonObject.java:191)
              ...
      
      Description: charTyped event handler
      
      java.lang.ClassCastException: com.google.gson.JsonPrimitive cannot be cast to com.google.gson.JsonArray
      	at com.google.gson.JsonObject.getAsJsonArray(JsonObject.java:181)
              ...
      
      Description: keyPressed event handler
      
      java.lang.IllegalStateException
      	at com.google.gson.JsonArray.getAsString(JsonArray.java:215)
              ...
      

      How to reproduce

      1. Use the following command
        /setblock ~ ~ ~ command_block{Command:"/tellraw @p {\"text\":[]}",auto:1b}
        
      2. Look in the log

            dinnerbone [Mojang] Nathan Adams
            marcono1234 Marcono1234
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: