fix: Properly escape new line characters in webhook (#8054)

This commit is contained in:
Eric Hare 2025-05-15 09:21:58 -07:00 committed by GitHub
commit 952633f4ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -43,7 +43,8 @@ class WebhookComponent(Component):
self.status = "No data provided."
return Data(data={})
try:
body = json.loads(self.data or "{}")
my_data = self.data.replace('"\n"', '"\\n"')
body = json.loads(my_data or "{}")
except json.JSONDecodeError:
body = {"payload": self.data}
message = f"Invalid JSON payload. Please check the format.\n\n{self.data}"