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
{{ message }}
Repository navigation
[🐛 Bug]: HTTP provider sends double-encoded JSON when workflow body uses {{ alert }} template #6547
, Keep's template engine renders {{ alert }} into a JSON string (e.g. '{"id": "123", ...}'). That string is then passed to requests.post(json=body), which serialises it again — sending a JSON-encoded string (""..."") to the target endpoint instead of a JSON object ({...}). The receiving endpoint gets the wrong content type and payload shape.
Thanks for the detailed report — I can confirm this is a real issue in the codebase.
The root cause is a two-step serialization problem:
Template rendering stringifies the alert: AlertDto.__str__() returns json.dumps(self.dict(), ...)[1], and the template engine (IOHandler) calls str(val) on rendered values [2]. So by the time body reaches the HTTP provider, it's already a JSON string like '{"id": "123", ...}'.
HTTP provider always uses json=: The _notify() method unconditionally passes the body via requests.post(..., json=body)[3] with no type check. When body is a string, requests calls json.dumps() on it again, producing a double-encoded payload ("\"...\"") on the wire.
A fix could check the body type before choosing the serialization strategy, e.g.:
ifisinstance(body, str):
try:
body=json.loads(body) # attempt to parse back to dictexcept (json.JSONDecodeError, TypeError):
passifisinstance(body, dict):
response=requests.post(url, json=body, headers=headers)
else:
response=requests.post(url, data=body, headers=headers)
This is also related to #6488 , where dict-type workflow parameters containing expressions get stringified via str(val) instead of being preserved as dicts in the template rendering layer.
Activity
dosubot commentedon May 28, 2026
Thanks for the detailed report — I can confirm this is a real issue in the codebase.
The root cause is a two-step serialization problem:
Template rendering stringifies the alert:
AlertDto.__str__()returnsjson.dumps(self.dict(), ...)[1], and the template engine (IOHandler) callsstr(val)on rendered values [2]. So by the timebodyreaches the HTTP provider, it's already a JSON string like'{"id": "123", ...}'.HTTP provider always uses
json=: The_notify()method unconditionally passes the body viarequests.post(..., json=body)[3] with no type check. Whenbodyis a string,requestscallsjson.dumps()on it again, producing a double-encoded payload ("\"...\"") on the wire.A fix could check the body type before choosing the serialization strategy, e.g.:
This is also related to #6488 , where dict-type workflow parameters containing expressions get stringified via
str(val)instead of being preserved as dicts in the template rendering layer.To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
fix(http-provider): don't double-encode a templated JSON body