pengrad / java-telegram-bot-api

Telegram Bot API for Java
https://core.telegram.org/bots
Apache License 2.0
1.81k stars 373 forks source link

Serialization conflict with 'thumbnail' field in InputPaidMedia and InputPaidMediaVideo classes #396

Closed mr-koibash closed 2 months ago

mr-koibash commented 2 months ago

Hi, I've encountered an issue while working with the InputPaidMedia and InputPaidMediaVideo classes in your library. There seems to be a serialization conflict due to the 'thumbnail' field being present in both classes.

Details:

Exception in thread "main" java.lang.IllegalArgumentException: Class com.pengrad.telegrambot.model.request.InputPaidMediaVideo declares multiple JSON fields named 'thumbnail'; conflict is caused by fields com.pengrad.telegrambot.model.request.InputPaidMediaVideo#thumbnail and com.pengrad.telegrambot.model.request.InputPaidMedia#thumbnail
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:302)
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:130)
  at com.google.gson.Gson.getAdapter(Gson.java:556)
  at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:55)
  at com.google.gson.internal.bind.ArrayTypeAdapter.write(ArrayTypeAdapter.java:104)
  at com.google.gson.Gson.toJson(Gson.java:842)
  at com.google.gson.Gson.toJson(Gson.java:812)
  at com.google.gson.Gson.toJson(Gson.java:759)
  at com.google.gson.Gson.toJson(Gson.java:736)
  at com.pengrad.telegrambot.impl.TelegramBotClient.toParamValue(TelegramBotClient.java:149)
  at com.pengrad.telegrambot.impl.TelegramBotClient.createRequestBody(TelegramBotClient.java:137)
  at com.pengrad.telegrambot.impl.TelegramBotClient.createRequest(TelegramBotClient.java:101)
  at com.pengrad.telegrambot.impl.TelegramBotClient.send(TelegramBotClient.java:77)
  at com.pengrad.telegrambot.TelegramBot.execute(TelegramBot.java:45)

Environment:

pengrad commented 2 months ago

Whole "SendPaidMedia" was working incorrectly. Fixed in 7.9.1 Thank you!