rubenlagus / TelegramBots

Java library to create bots using Telegram Bots API
https://telegram.me/JavaBotsApi
MIT License
4.79k stars 1.23k forks source link

Wrong validation in SendPaidMedia #1422

Open PeterFit opened 2 months ago

PeterFit commented 2 months ago

Describe the bug When trying to execute SendPaidMedia - validation error occured Number of media should be between 2 and 10. According to documentation (https://core.telegram.org/bots/api#sendpaidmedia) - there is no lower limit for medias, only "up to 10".

Also, if trying to duplicate media (to pass broken validation) - an error occurrs in logs

  at org.telegram.telegrambots.meta.api.methods.botapimethods.PartialBotApiMethod.deserializeResponseInternal(PartialBotApiMethod.java:64) ~[telegrambots-meta-7.9.1.jar:na]
  at org.telegram.telegrambots.meta.api.methods.botapimethods.PartialBotApiMethod.deserializeResponseArray(PartialBotApiMethod.java:46) ~[telegrambots-meta-7.9.1.jar:na]
  at org.telegram.telegrambots.meta.api.methods.send.SendPaidMedia.deserializeResponse(SendPaidMedia.java:138) ~[telegrambots-meta-7.9.1.jar:na]
  at org.telegram.telegrambots.meta.api.methods.send.SendPaidMedia.deserializeResponse(SendPaidMedia.java:32) ~[telegrambots-meta-7.9.1.jar:na]
  at org.telegram.telegrambots.client.okhttp.OkHttpFutureCallback.onResponse(OkHttpFutureCallback.java:35) ~[telegrambots-client-7.9.1.jar:na]
  at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519) ~[okhttp-4.12.0.jar:na]
  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
  at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.util.ArrayList<org.telegram.telegrambots.meta.api.objects.message.Message>` from Object value (token `JsonToken.START_OBJECT`)
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 21] (through reference chain: org.telegram.telegrambots.meta.api.objects.ApiResponse["result"])
  at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59) ~[jackson-databind-2.17.2.jar:2.17.2]
  at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1767) ~[jackson-databind-2.17.2.jar:2.17.2]
  at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1541) ~[jackson-databind-2.17.2.jar:2.17.2]
  at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1488) ~[jackson-databind-2.17.2.jar:2.17.2]
  at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.handleNonArray(CollectionDeserializer.java:402) ~[jackson-databind-2.17.2.jar:2.17.2]
  at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:254) ~[jackson-databind-2.17.2.jar:2.17.2]
  at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:30) ~[jackson-databind-2.17.2.jar:2.17.2]
  at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138) ~[jackson-databind-2.17.2.jar:2.17.2]
  at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:310) ~[jackson-databind-2.17.2.jar:2.17.2]
  at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177) ~[jackson-databind-2.17.2.jar:2.17.2]
  at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:342) ~[jackson-databind-2.17.2.jar:2.17.2]
  at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4905) ~[jackson-databind-2.17.2.jar:2.17.2]
  at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3848) ~[jackson-databind-2.17.2.jar:2.17.2]
  at org.telegram.telegrambots.meta.api.methods.botapimethods.PartialBotApiMethod.deserializeResponseInternal(PartialBotApiMethod.java:57) ~[telegrambots-meta-7.9.1.jar:na]
  ... 8 common frames omitted

Steps to reproduce: just send SendPaidMedia with 1 media.