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

JsonResponse constructor missing in newsletter makes all newsletter handlers and functions fail #534

Open
Thomas-Pellan opened this issue Dec 24, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Thomas-Pellan
Copy link

Hello, hope you are going well

While implementing some changes regarding Whatsapp channels I stepped on these issues that seem related :

Follow and unfollow events cause the following error to be triggered :

java.io.UncheckedIOException: Cannot read json
	at it.auties.whatsapp.util.Json.readValue(Json.java:99)
	at it.auties.whatsapp.model.response.NewsletterResponse.ofJson(NewsletterResponse.java:21)
	at it.auties.whatsapp.implementation.StreamHandler.handleNewsletterJoin(StreamHandler.java:478)
	at it.auties.whatsapp.implementation.StreamHandler.handleMexNamespace(StreamHandler.java:433)
	at it.auties.whatsapp.implementation.StreamHandler.digestNotification(StreamHandler.java:374)
	at it.auties.whatsapp.implementation.StreamHandler.digest(StreamHandler.java:117)
	at it.auties.whatsapp.implementation.SocketHandler.onMessage(SocketHandler.java:199)
	at it.auties.whatsapp.implementation.SocketSession$WebSocketSession.onMessage(SocketSession.java:119)
	at it.auties.whatsapp.net.WebSocketClient$MessageDecoder.payloadData(WebSocketClient.java:442)
	at it.auties.whatsapp.net.WebSocketClient$MessageDecoder.handlePayloadData(WebSocketClient.java:282)
	at it.auties.whatsapp.net.WebSocketClient$MessageDecoder.handleFrame(WebSocketClient.java:268)
	at it.auties.whatsapp.net.WebSocketClient$MessageDecoder.readFrame(WebSocketClient.java:255)
	at it.auties.whatsapp.net.WebSocketClient.lambda$listen$1(WebSocketClient.java:93)
	at it.auties.whatsapp.net.Response.complete(Response.java:8)
	at it.auties.whatsapp.net.SocketClient$SocketTransport$Secure.decodeSslBuffer(SocketClient.java:843)
	at it.auties.whatsapp.net.SocketClient$SocketTransport$Secure.lambda$fillSslBuffer$2(SocketClient.java:829)
	at it.auties.whatsapp.net.Response.complete(Response.java:8)
	at it.auties.whatsapp.net.SocketClient$SocketTransport$1.completed(SocketClient.java:563)
	at it.auties.whatsapp.net.SocketClient$SocketTransport$1.completed(SocketClient.java:549)
	at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:129)
	at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finishRead(UnixAsynchronousSocketChannelImpl.java:447)
	at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finish(UnixAsynchronousSocketChannelImpl.java:195)
	at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.onEvent(UnixAsynchronousSocketChannelImpl.java:217)
	at java.base/sun.nio.ch.EPollPort$EventHandlerTask.run(EPollPort.java:305)
	at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `it.auties.whatsapp.model.response.NewsletterResponse$JsonResponse` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: (String)"{"data":{"xwa2_notify_newsletter_on_join":{"id":"120363182044819404@newsletter","state":{"type":"ACTIVE"},"thread_metadata":{"creation_time":"1700490696","description":{"id":"1700490696485485","text":"Chaque jour de la semaine, Le Monde des ados te partage une info \u00e0 la sortie des cours.\n\nConseils perso, recos culturelles, \u00e9clairages sur l\u2019actu et quiz sign\u00e9s par la r\u00e9daction.","update_time":"1700490696485485"},"followers_count":"95780","handle":null,"image":null,"invi"[truncated 688 chars]; line: 1, column: 2]
	at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
	at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1915)
	at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:414)
	at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1360)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1424)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:352)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:185)
	at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4825)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3772)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3740)
	at it.auties.whatsapp.util.Json.readValue(Json.java:97)

This error is triggered in NewsletterResponse that is used in handleNewsletterJoin/handleNewsletterLeave/handleNewsletterMute from what I could see. Consequently, the newsletter store is never updated and that causes the listener on newsletter new messages to fail, as findNewsletterByJid queries a always empty store.

Versions tested : 0.0.6 and 0.0.7

Hopes this is not too much of a pain to fix, thanks a lot for this project and your work ! I tried to implement Baileys in java on my own but failed and this is just what I need for my project.

@Auties00 Auties00 added the bug Something isn't working label Dec 25, 2024
@Auties00
Copy link
Owner

I’ll have this fixed when I release 1.0, I first have to finish rewriting the network stack into the Leap repository though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants