BotMill / fb-botmill

A Java framework for building bots on Facebook's Messenger Platform.
MIT License
72 stars 26 forks source link

Nullpointer exception when rendering a list or generic template #35

Closed alvin-reyes closed 7 years ago

alvin-reyes commented 7 years ago

The bot seems to be rendering it perfectly but an exception is thrown every time it does it

2017-01-01T01:11:44.084430+00:00 app[web.1]: 01:11:44.084 [http-nio-43734-exec-6] ERROR c.a.botmill.fb.FbBotMillServlet - Error during MessengerCallback parsing: 2017-01-01T01:11:44.084432+00:00 app[web.1]: java.lang.NullPointerException: null 2017-01-01T01:11:44.084433+00:00 app[web.1]: at com.google.gson.internal.$Gson$Preconditions.checkNotNull($Gson$Preconditions.java:39) ~[gson-2.7.jar:na] 2017-01-01T01:11:44.084433+00:00 app[web.1]: at com.google.gson.reflect.TypeToken.(TypeToken.java:72) ~[gson-2.7.jar:na] 2017-01-01T01:11:44.084434+00:00 app[web.1]: at com.google.gson.reflect.TypeToken.get(TypeToken.java:296) ~[gson-2.7.jar:na] 2017-01-01T01:11:44.084435+00:00 app[web.1]: at com.google.gson.Gson.fromJson(Gson.java:885) ~[gson-2.7.jar:na] 2017-01-01T01:11:44.084436+00:00 app[web.1]: at com.google.gson.Gson.fromJson(Gson.java:952) ~[gson-2.7.jar:na] 2017-01-01T01:11:44.084436+00:00 app[web.1]: at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162) ~[gson-2.7.jar:na]

aurasphere commented 7 years ago

If you need any help I could take a look at this, since I think is related to the serializer I made.

aurasphere commented 7 years ago

Do you have any test case to replicate this issue?

alvin-reyes commented 7 years ago

Sample Input (we send to facebook):

{"object":"page","entry":[{"id":"1423903854504468","time":1483578464976,"messaging":[{"sender":{"id":"1158621824216736"},"recipient":{"id":"1423903854504468"},"timestamp":1483578464976,"delivery":{"mids":["mid.1483578464765:ed1fe23f35"],"watermark":1483578464765,"seq":0}}]}]}

This is the json output response from facebook:

{"object":"page","entry":[{"id":"1423903854504468","time":1483578465379,"messaging":[{"sender":{"id":"1423903854504468"},"recipient":{"id":"1158621824216736"},"timestamp":1483578464765,"message":{"is_echo":true,"app_id":618775588324375,"mid":"mid.1483578464765:ed1fe23f35","seq":785209,"attachments":[{"title":"Title2, Title1, Title3, Title4","url":"https:\/\/www.facebook.com\/commerce\/update\/","type":"template","payload":{"template_type":"list","sharable":false,"elements":[{"title":"Title2","item_url":"http:\/\/www.alvinjayreyes.com\/","image_url":"http:\/\/blog.domainmonkee.com\/wp-content\/uploads\/2014\/05\/url.jpg","subtitle":"This is a sample sub title for your product","buttons":[{"type":"postback","title":"View","payload":"view"}],"default_action":{"type":"web_url","url":"http:\/\/www.alvinjayreyes.com\/"}},{"title":"Title1","item_url":"http:\/\/www.alvinjayreyes.com\/","image_url":"https:\/\/lh4.ggpht.com\/mJDgTDUOtIyHcrb69WM0cpaxFwCNW6f0VQ2ExA7dMKpMDrZ0A6ta64OCX3H-NMdRd20=w300","subtitle":"This is a sample sub title for your product","buttons":[{"type":"postback","title":"View","payload":"view"}],"default_action":{"type":"web_url","url":"http:\/\/www.alvinjayreyes.com\/"}},{"title":"Title3","item_url":"http:\/\/www.alvinjayreyes.com\/","image_url":"http:\/\/blog.domainmonkee.com\/wp-content\/uploads\/2014\/05\/url.jpg","subtitle":"This is a sample sub title for your product","buttons":[{"type":"postback","title":"View","payload":"view"}],"default_action":{"type":"web_url","url":"http:\/\/www.alvinjayreyes.com\/"}},{"title":"Title4","item_url":"http:\/\/www.alvinjayreyes.com\/","image_url":"http:\/\/blog.domainmonkee.com\/wp-content\/uploads\/2014\/05\/url.jpg","subtitle":"This is a sample sub title for your product","buttons":[{"type":"postback","title":"View","payload":"view"}],"default_action":{"type":"web_url","url":"http:\/\/www.alvinjayreyes.com\/"}}],"buttons":[{"type":"postback","title":"Just Sample","payload":"Yes"}]}}]}}]}]}