benkehoe / sfn-callback-urls

An application for easy handling of Step Function tokens as callback URLs
Apache License 2.0
47 stars 14 forks source link

Post action body must be JSON #6

Closed adriandieter closed 3 years ago

adriandieter commented 3 years ago

Post to callback url does not succeed due to InvalidPostActionBody. However the posted body is valid JSON and the Content-Type header is set to application/json;charset=utf-8.

It seems like the problem is a strict match of the Content-Type to application/json, which fails when the charset is specified in the Content-Type header.

Could this comparison be the problem? https://github.com/benkehoe/sfn-callback-urls/blob/f82c6039c794094c3da0bd4e91935317a0a40ca6/src/sfn_callback_urls/post_actions.py#L49

Example Post and log message:

Post to Callback: Content-Type: application/json;charset=utf-8

{
    "source": "foo",
    "id": "bar",
    "state": "success",
}

Log of ProcessCallbackFunction:

{
    "timestamp": "2020-12-11T09:56:14.576580",
    "decode_time": 0.29622951199996805,
    "transaction_id": "xxx",
    "action": {
        "name": "post",
        "type": "post"
    },
    "error": {
        "type": "RequestError",
        "error": "InvalidPostActionBody",
        "message": "Post action body must be JSON"
    }
}
benkehoe commented 3 years ago

Thanks, I'll take care of this. Also a good time to update the Python runtime and dependencies.

benkehoe commented 3 years ago

This is fixed, both in the source and in the SAR app. Funnily enough, I was already parsing this correctly for Accept headers.

adriandieter commented 3 years ago

Cool, thank you! 🙌