Skip to content

Verify webhook URL causes KeyError: 'destination' with 1.12.0 #186

@tsaiid

Description

@tsaiid

The release of 1.12.0 introduced a feature:

However, when trying to verify the webhook URL in the developers console, the request body does not have a destination tag, as below:

{
  "events": [
    {
      "replyToken": "00000000000000000000000000000000",
      "type": "message",
      "timestamp": 1561099010135,
      "source": {
        "type": "user",
        "userId": "Udeadbeefdeadbeefdeadbeefdeadbeef"
      },
      "message": {
        "id": "100001",
        "type": "text",
        "text": "Hello, world"
      }
    },
    {
      "replyToken": "ffffffffffffffffffffffffffffffff",
      "type": "message",
      "timestamp": 1561099010135,
      "source": {
        "type": "user",
        "userId": "Udeadbeefdeadbeefdeadbeefdeadbeef"
      },
      "message": {
        "id": "100002",
        "type": "sticker",
        "packageId": "1",
        "stickerId": "1"
      }
    }
  ]
}

Then a KeyErr will be evoked.

Traceback (most recent call last):
  File "/home/ittsai/.local/share/virtualenvs/femhrad-linebot-QHVSuSA1/lib/python3.7/site-packages/flask/app.py", line 2311, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/ittsai/.local/share/virtualenvs/femhrad-linebot-QHVSuSA1/lib/python3.7/site-packages/flask/app.py", line 1834, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/ittsai/.local/share/virtualenvs/femhrad-linebot-QHVSuSA1/lib/python3.7/site-packages/flask/app.py", line 1737, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/ittsai/.local/share/virtualenvs/femhrad-linebot-QHVSuSA1/lib/python3.7/site-packages/flask/_compat.py", line 36, in reraise
    raise value
  File "/home/ittsai/.local/share/virtualenvs/femhrad-linebot-QHVSuSA1/lib/python3.7/site-packages/flask/app.py", line 1832, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/ittsai/.local/share/virtualenvs/femhrad-linebot-QHVSuSA1/lib/python3.7/site-packages/flask/app.py", line 1818, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/ittsai/git/femhrad-linebot/callback.py", line 149, in callback
    handler.handle(body, signature)
  File "/home/ittsai/.local/share/virtualenvs/femhrad-linebot-QHVSuSA1/lib/python3.7/site-packages/linebot/webhook.py", line 235, in handle
    payload = self.parser.parse(body, signature, as_payload=True)
  File "/home/ittsai/.local/share/virtualenvs/femhrad-linebot-QHVSuSA1/lib/python3.7/site-packages/linebot/webhook.py", line 175, in parse
    return WebhookPayload(events=events, destination=body_json['destination'])
KeyError: 'destination'

My callback server is base on line-bot-sdk-python/examples/flask-echo/app.py

I think this situation may be handled in the SDK level.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions