mojira.dev
MC-121806

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

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.

[^(17w45b) crash-2017-11-10_22.17.47-client.txt]

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)
        ...

[^(17w45b) crash-2017-11-10_22.26.44-client.txt]

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)
        ...

[^(17w45b) crash-2017-11-10_22.31.10-client.txt]

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

Attachments

Comments 1

Is this still an issue in 18w01a?

marcono1234

Nathan Adams

Confirmed

/tellraw, json, text-component

Minecraft 17w45b

Minecraft 1.13.1

Retrieved