Skip to content

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

Closed
@mr-koibash

Description

@mr-koibash

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:

  • The InputPaidMedia class has a thumbnail field.
  • The InputPaidMediaVideo class, which extends InputPaidMedia, also has a thumbnail field.
  • This causes a conflict during JSON serialization/deserialization, resulting in the following error:
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:

  • Library version: 7.9.0
  • Java version: 21

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions