Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot will stuck in infinite loop when receive "group upgraded to supergroup" message #44

Closed
makkarpov opened this issue Oct 16, 2017 · 1 comment

Comments

@makkarpov
Copy link
Contributor

makkarpov commented Oct 16, 2017

Steps to reproduce:

  1. Create group
  2. Add bot (without group privacy) to it
  3. Upgrade to supergroup

Expected behavior:

Bot will correctly handle all these events

Actual behavior:

Bot cannot parse one of the update messages and fails with:

[info] No usable value for id
[info] Did not find value which can be converted into long
[info]  at org.json4s.reflect.package$.fail(package.scala:95)
[info]  at org.json4s.Extraction$ClassInstanceBuilder.org$json4s$Extraction$ClassInstanceBuilder$$buildCtorArg(Extraction.scala:526)
[info]  at org.json4s.Extraction$ClassInstanceBuilder$$anonfun$15.apply(Extraction.scala:546)
[info]  at org.json4s.Extraction$ClassInstanceBuilder$$anonfun$15.apply(Extraction.scala:546)
[info]  at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
[info]  at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
[info]  at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
[info]  at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
[info]  at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
[info]  at scala.collection.AbstractTraversable.map(Traversable.scala:104)
[info] Caused by: org.json4s.package$MappingException: No usable value for id
[info] Did not find value which can be converted into long
[info]  at org.json4s.reflect.package$.fail(package.scala:95)
[info]  at org.json4s.Extraction$ClassInstanceBuilder.org$json4s$Extraction$ClassInstanceBuilder$$buildCtorArg(Extraction.scala:526)
[info]  at org.json4s.Extraction$ClassInstanceBuilder$$anonfun$15.apply(Extraction.scala:546)
[info]  at org.json4s.Extraction$ClassInstanceBuilder$$anonfun$15.apply(Extraction.scala:546)
[info]  at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
[info]  at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
[info]  at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
[info]  at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
[info]  at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
[info]  at scala.collection.AbstractTraversable.map(Traversable.scala:104)
[info] Caused by: org.json4s.package$MappingException: Did not find value which can be converted into long
[info]  at org.json4s.reflect.package$.fail(package.scala:95)
[info]  at org.json4s.Extraction$$anonfun$org$json4s$Extraction$$convert$2.apply(Extraction.scala:704)
[info]  at org.json4s.Extraction$$anonfun$org$json4s$Extraction$$convert$2.apply(Extraction.scala:704)
[info]  at scala.Option.getOrElse(Option.scala:121)
[info]  at org.json4s.Extraction$.org$json4s$Extraction$$convert(Extraction.scala:704)
[info]  at org.json4s.Extraction$$anonfun$extract$6.apply(Extraction.scala:394)
[info]  at org.json4s.Extraction$$anonfun$extract$6.apply(Extraction.scala:392)
[info]  at org.json4s.Extraction$.customOrElse(Extraction.scala:606)
[info]  at org.json4s.Extraction$.extract(Extraction.scala:392)
[info]  at org.json4s.Extraction$ClassInstanceBuilder.org$json4s$Extraction$ClassInstanceBuilder$$buildCtorArg(Extraction.scala:514)

Telegram4s v3.0.9

@mukel
Copy link
Member

mukel commented Oct 16, 2017

Got it, thanks for reporting!
I pushed a fix (786ef9c) to v3.0.13, which is also updated to the latest Telegram Bot API (v3.4).

Overview

Just a de-serialization issue; these are easy to fix, but hard to find.
I'll look some property-based testing library so I can fuzz the (de)serialization routines.

Issue

Some fields (Message.migratetoChatId) were typed ChatId.Chat, serialization was covered for the super type ChatId but not for ChatId.Chat.

Fix

Replace ChatId.Chat by Long. This is the least-resistance solution. Also considered adding yet another custom serializer for ChatId.Chat.

Compatibility issues

This change should be transparent for most users, except for a few methods that expect Option[ChatId].
e.g.

SendGame(msg.source, ...)

becomes

SendGame(ChatId(msg.source), ...)

@mukel mukel closed this as completed Oct 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants