Initializing specialized messages with base_msg set fails
The constructor of UserMessage
pretends to accept an input for base_msg
of type string
,byte
and dict
. Because the input is validated using raise_error_from_s3ib_msg
(which expects a dict as input) an exception is raised for all types that are not dict
. Passing an arbitrary dict
to the constructor will fail as well, because it has to match some requirements specified by a json schema. Also, the requirements are not documented. There are multiple options to solve this problems:
- only accept
dict
objects, describe the requirements for it in the docstring and remove other else statements - remove
base_msg
from constructor and force users to usefillUserMessage
- "merge" functionality of
fillUserMessage
into constructor - builder style: `message = UserMessage().fillUserMessage(sender="s3i:abcd", ...).fillPgpMessage(...).fillGzipMessage(...)
All message classes are affected by this issue.
NOTE: Passing a user defined message to the constructor opens up the possibility to inject different messages. This means, you can pass a dictionary describing a ServiceRequest to the constructor of an UserMessage and it works.
UPDATE: The fact that the setter method for Message.base_msg only accepts dict
type objects, is an additional pointer that something is wrong.