mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 05:27:35 +00:00
fix: prevent TypeError in Teams webhook when user data is missing (#22444)
json.loads(event_data.get("user", {})) crashes with TypeError when
the "user" key is absent because the default value {} is a dict, not
a JSON string. json.loads expects str/bytes, not dict.
Also handle the case where "user" is already a dict (not serialized
JSON) to make the webhook more robust.
Co-authored-by: gambletan <ethanchang32@gmail.com>
This commit is contained in:
parent
f78b238b40
commit
3e513be963
1 changed files with 6 additions and 1 deletions
|
|
@ -26,9 +26,14 @@ async def post_webhook(name: str, url: str, message: str, event_data: dict) -> b
|
|||
# Microsoft Teams Webhooks
|
||||
elif "webhook.office.com" in url:
|
||||
action = event_data.get("action", "undefined")
|
||||
user_data = event_data.get("user", "{}")
|
||||
if isinstance(user_data, dict):
|
||||
user_dict = user_data
|
||||
else:
|
||||
user_dict = json.loads(user_data)
|
||||
facts = [
|
||||
{"name": name, "value": value}
|
||||
for name, value in json.loads(event_data.get("user", {})).items()
|
||||
for name, value in user_dict.items()
|
||||
]
|
||||
payload = {
|
||||
"@type": "MessageCard",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue