cofacts / rumors-line-bot

Line bot that checks if a message contains internet rumor.
MIT License
77 stars 19 forks source link

[LINE Client] 400: A message (messages[1]) in the request body is invalid. #125

Open MrOrz opened 5 years ago

MrOrz commented 5 years ago

View details in Rollbar: https://rollbar.com/mrorz/rumors-line-bot/items/59/

[LINE Client] 400: A message (messages[1]) in the request body is invalid.
MrOrz commented 5 years ago

Making ratings to exceed 10 causes reply overlength

MrOrz commented 5 years ago

Sometimes it's the URL too long. https://rollbar.com/mrorz/rumors-line-bot/items/59/occurrences/67049635923/

MrOrz commented 5 years ago

This happens quite frequently and is eating up our rollbar quota. Suggest to get it fixed soon.

nonumpa commented 5 years ago

Error msg : [{"message": "size must be between 0 and 1000", "property": "template/actions/0/uri"}]

In PR #119 utils.js's function createArticleShareReply don't use ellipsis and it may create a message size longer than 1000. But the reply contains uri if we ellipsis it, user click the button will get a wrong result. Need more discussion!

MrOrz commented 5 years ago

Let's truncate the user input reason before creating line:// URLs?

We can pick a length limit that is definitely safe (such as 100 words) so that it will not exceed the limit even after URL encoding.

MrOrz commented 5 years ago

看起來這次還有 reply 文字太長,導致無法查詢該則回應 orz

https://rollbar.com/mrorz/rumors-line-bot/items/54/occurrences/78068581282/ 當 LINE bot 試圖顯示這個回應的時候,就會壞掉: https://cofacts.g0v.tw/reply/BWHDyGoBFV14knB4E2x8

MrOrz commented 5 years ago

訊息裡頭如果有「#」的話,似乎會被 LINE 判定為 invalid uri scheme⋯⋯ 例:https://rollbar.com/mrorz/rumors-line-bot/items/59/occurrences/102203000877/

request.body:

{"replyToken":"5a0f8038d1234d32b8c77e0ca1ffc8f3","messages":[{"type":"text","text":"感謝您與其他 10 人的回饋。"},{"type":"template","altText":"📲 別忘了把上面的回應轉傳回您的聊天室,給其他人也看看!\n💁 若您認為自己能回應得更好,歡迎到 https://cofacts.g0v.tw/article/AV_JIY36yCdS-nWhujUU 提交新的回應唷!","template":{"type":"confirm","text":"📲 別忘了把上面的回應轉傳回您的聊天室,給其他人也看看!\n💁 若您認為自己能回應得更好,歡迎提交新的回應唷!","actions":[{"type":"uri","label":"分享給朋友","uri":"line://msg/text/?%E7%B6%B2%E8%B7%AF%E4%B8%8A%E6%9C%89%E4%BA%BA%E8%AA%AA%E3%80%8C#%E5%B0%8F%E5%BF%83%0A#%E5%9C%8B%E9%9A%9B%E7%B4%9A%E6%AF%92%E8%8D%89%E5%9C%A8%E5%8F%B0%E7%81%A3%E2%8B%AF%E2%8B%AF%E3%80%8D%20%E5%90%AB%E6%9C%89%E4%B8%8D%E5%AF%A6%E8%A8%8A%E6%81%AF%E5%96%94%EF%BC%81%0A%0A%E8%AB%8B%E8%87%B3%20https://cofacts.g0v.tw/article/AV_JIY36yCdS-nWhujUU%20%E7%9C%8B%E7%9C%8B%E9%84%89%E8%A6%AA%E5%80%91%E9%87%9D%E5%B0%8D%E9%80%99%E5%89%87%E8%A8%8A%E6%81%AF%E7%9A%84%E5%9B%9E%E6%87%89%E3%80%81%E7%90%86%E7%94%B1%EF%BC%8C%E8%88%87%E7%9B%B8%E9%97%9C%E7%9A%84%E5%87%BA%E8%99%95%E5%94%B7%EF%BC%81"},{"type":"uri","label":"提交新回應","uri":"https://cofacts.g0v.tw/article/AV_JIY36yCdS-nWhujUU"}]}}]}

result.details

[{"message": "invalid uri", "property": "template/actions/0/uri"}, {"message": "invalid uri scheme", "property": "template/actions/0/uri"}]

result.message

A message (messages[1]) in the request body is invalid
MrOrz commented 5 years ago

看起來應該是 hashtag 的問題,最近的 occurrence 都有 hashtag

https://rollbar.com/mrorz/rumors-line-bot/items/59/

ex:

line://msg/text/?%E7%B6%B2%E8%B7%AF%E4%B8%8A%E6%9C%89%E4%BA%BA%E8%AA%AA%E3%80%8C#%E5%B0%8F%E5%BF%83%0A#%E5%9C%8B%E9%9A%9B%E7%B4%9A%E6%AF%92%E8%8D%89%E5%9C%A8%E5%8F%B0%E7%81%A3%E2%8B%AF%E2%8B%AF%E3%80%8D%20%E5%90%AB%E6%9C%89%E4%B8%8D%E5%AF%A6%E8%A8%8A%E6%81%AF%E5%96%94%EF%BC%81%0A%0A%E8%AB%8B%E8%87%B3%20https://cofacts.g0v.tw/article/AV_JIY36yCdS-nWhujUU%20%E7%9C%8B%E7%9C%8B%E9%84%89%E8%A6%AA%E5%80%91%E9%87%9D%E5%B0%8D%E9%80%99%E5%89%87%E8%A8%8A%E6%81%AF%E7%9A%84%E5%9B%9E%E6%87%89%E3%80%81%E7%90%86%E7%94%B1%EF%BC%8C%E8%88%87%E7%9B%B8%E9%97%9C%E7%9A%84%E5%87%BA%E8%99%95%E5%94%B7%EF%BC%81

{"replyToken":"xxx","messages":[{"type":"text","text":"感謝您與其他 99 人的回饋。"},{"type":"template","altText":"📲 別忘了把上面的回應轉傳回您的聊天室,給其他人也看看!\n💁 若您認為自己能回應得更好,歡迎到 https://cofacts.g0v.tw/article/AV_JIY36yCdS-nWhujUU 提交新的回應唷!","template":{"type":"confirm","text":"📲 別忘了把上面的回應轉傳回您的聊天室,給其他人也看看!\n💁 若您認為自己能回應得更好,歡迎提交新的回應唷!","actions":[{"type":"uri","label":"分享給朋友","uri":"line://msg/text/?%E7%B6%B2%E8%B7%AF%E4%B8%8A%E6%9C%89%E4%BA%BA%E8%AA%AA%E3%80%8C#%E5%B0%8F%E5%BF%83%0A#%E5%9C%8B%E9%9A%9B%E7%B4%9A%E6%AF%92%E8%8D%89%E5%9C%A8%E5%8F%B0%E7%81%A3%E2%8B%AF%E2%8B%AF%E3%80%8D%20%E5%90%AB%E6%9C%89%E4%B8%8D%E5%AF%A6%E8%A8%8A%E6%81%AF%E5%96%94%EF%BC%81%0A%0A%E8%AB%8B%E8%87%B3%20https://cofacts.g0v.tw/article/AV_JIY36yCdS-nWhujUU%20%E7%9C%8B%E7%9C%8B%E9%84%89%E8%A6%AA%E5%80%91%E9%87%9D%E5%B0%8D%E9%80%99%E5%89%87%E8%A8%8A%E6%81%AF%E7%9A%84%E5%9B%9E%E6%87%89%E3%80%81%E7%90%86%E7%94%B1%EF%BC%8C%E8%88%87%E7%9B%B8%E9%97%9C%E7%9A%84%E5%87%BA%E8%99%95%E5%94%B7%EF%BC%81"},{"type":"uri","label":"提交新回應","uri":"https://cofacts.g0v.tw/article/AV_JIY36yCdS-nWhujUU"}]}}]}
--