lambda-decorators icon indicating copy to clipboard operation
lambda-decorators copied to clipboard

`load_json_body` is triggered only when `event["body"]` is a string. Is there a good reason for it?

Open martinezpl opened this issue 3 years ago • 0 comments

Because I only see reasons against it:

  1. Simply because a JSON can be passed also as bytes - hence json.loads() method accepts types of bytes and bytearray as well.
  2. If I decide to use this decorator on a handler it means I expect a JSON in the body, therefore I'd like it to return a 400 even when the input is not a string. This could be skipped it the body is already a dictionary.

I understand changing the logic to start acting on non-strings is most likely breaking. If a maintainer gives a green light, I can create a PR.

Also, I am curious of other opinions.

martinezpl avatar Jul 27 '22 17:07 martinezpl