Fix ClassCastException for invalid payloads.