You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The events produced on the platform.inventory.host-egress topic are currently double-encoded to JSON.
First encoding happens in the app.queue.egress.build_host_event function, where Marshmallow Schema is used to validate and encode the event dictionary. This produces a JSON string.
The result is a JSON string (not a dictionary) containing properly-escaped JSON dictionary literal. "{\"type\":\"created\"}" instead of {"type":"created"}. That means that if a client decodes the message, it doesn’t get the dictionary, but a string, which must be decoded again.
Possible solutions:
Don’t use Marshmallow to validate messages that our code produce. These messages should be tested and thus trusted.
Pass the Marshmallow object instead of an encoded string. Make the producer wrapper expect such objects and dump them directly to the queue.
Passing down the Marshmallow object is an easy and quite ok solution.
I am disappoint that there are no tests for the message format. A bug like this would be probably caught by a test.
The text was updated successfully, but these errors were encountered:
The events produced on the platform.inventory.host-egress topic are currently double-encoded to JSON.
The result is a JSON string (not a dictionary) containing properly-escaped JSON dictionary literal.
"{\"type\":\"created\"}"
instead of{"type":"created"}
. That means that if a client decodes the message, it doesn’t get the dictionary, but a string, which must be decoded again.Possible solutions:
Passing down the Marshmallow object is an easy and quite ok solution.
I am disappoint that there are no tests for the message format. A bug like this would be probably caught by a test.
The text was updated successfully, but these errors were encountered: