mautrix / discord

A Matrix-Discord puppeting bridge
https://go.mau.fi/mautrix-discord
GNU Affero General Public License v3.0
253 stars 21 forks source link

50035 : Invalid Form Body when relaying through webhooks #95

Closed Aeris1One closed 1 year ago

Aeris1One commented 1 year ago

Hi, I just bridged a room using webhooks (!discord bridge <discorroomid> then !discord set-relay <matrixroomid> --create), but when someone except the account I used to setup the bridge (which speaks, as intended, through the bot instead of through webhooks) I get back some ⚠ Your message was not bridged: 50035: Invalid Form Body as m.notice.

It looks like it is related to avatar urls which is sent in a wrong format to Discord. Here are debug logs :

Jun 20, 2023 10:16:40 DBG Sent message checkpoint message_checkpoint={"event_id":"$kViBySkWancHtehsL_qwTWG9GTju4RjXS-7d7bKSFyI","event_type":"m.room.message","message_type":"m.text","reported_by":"BRIDGE","retry_num":0,"room_id":"!roomid:my.domain","status":"SUCCESS","step":"BRIDGE","timestamp":1687256200361}
Jun 20, 2023 10:16:40 ERR Matrix event not handled error="HTTP 400 Bad Request, {\"code\": 50035, \"errors\": {\"avatar_url\": {\"_errors\": [{\"code\": \"URL_TYPE_INVALID_URL\", \"message\": \"Not a well formed URL.\"}]}}, \"message\": \"Invalid Form Body\"}" action="send matrix message metrics" channel_id=689171405384056933 channel_receiver= event_id=$kViBySkWancHtehsL_qwTWG9GTju4RjXS-7d7bKSFyI event_type=m.room.message result="Error sending event" room_id=!roomid:my.domain sender=@myaccount:my.domain
Jun 20, 2023 10:16:40 DBG Sending request as_user_id=@discordbot:my.domain body={"typing":false} method=PUT req_id=29 url=http://matrix-nginx-proxy:12080/_matrix/client/v3/rooms/%21roomid:my.domain/typing/@discordbot:my.domain?user_id=%40discordbot%3Amy.domain
Jun 20, 2023 10:16:40 DBG Sent message checkpoint message_checkpoint={"event_id":"$kViBySkWancHtehsL_qwTWG9GTju4RjXS-7d7bKSFyI","event_type":"m.room.message","info":"HTTP 400: 50035: Invalid Form Body ({\"avatar_url\":{\"_errors\":[{\"code\":\"URL_TYPE_INVALID_URL\",\"message\":\"Not a well formed URL.\"}]}})","message_type":"m.text","reported_by":"BRIDGE","retry_num":0,"room_id":"!roomid:my.domain","status":"PERM_FAILURE","step":"REMOTE","timestamp":1687256200507}
Jun 20, 2023 10:16:40 DBG Request completed as_user_id=@discordbot:my.domain duration=12.192771 method=PUT path=/v3/rooms/!roomid:my.domain/typing/@discordbot:my.domain req_id=29 response_length=2 response_mime=application/json status_code=200
Jun 20, 2023 10:16:40 DBG Sending request as_user_id=@discordbot:my.domain body={"body":"⚠ Your message was not bridged: 50035: Invalid Form Body","msgtype":"m.notice"} method=PUT req_id=30 url=http://matrix-nginx-proxy:12080/_matrix/client/v3/rooms/%21roomid:my.domain/send/m.room.message/mautrix-go_1687256200522469625_5?user_id=%40discordbot%3Amy.domain
Jun 20, 2023 10:16:40 DBG Request completed as_user_id=@discordbot:my.domain duration=102.904117 method=PUT path=/v3/rooms/!roomid:my.domain/send/m.room.message/mautrix-go_1687256200522469625_5 req_id=30 response_length=59 response_mime=application/json status_code=200
Jun 20, 2023 10:16:40 DBG Sending request as_user_id=@discordbot:my.domain body={"error":"HTTP 400: 50035: Invalid Form Body ({\"avatar_url\":{\"_errors\":[{\"code\":\"URL_TYPE_INVALID_URL\",\"message\":\"Not a well formed URL.\"}]}})","m.relates_to":{"event_id":"$kViBySkWancHtehsL_qwTWG9GTju4RjXS-7d7bKSFyI","rel_type":"m.reference"},"message":"50035: Invalid Form Body","network":"fi.mau.discord://discord/689159304049197131/689171405384056933","reason":"m.event_not_handled","status":"FAIL_PERMANENT"} method=PUT req_id=31 url=http://matrix-nginx-proxy:12080/_matrix/client/v3/rooms/%21roomid:my.domain/send/com.beeper.message_send_status/mautrix-go_1687256200630975471_6?user_id=%40discordbot%3Amy.domain

EDIT : Isn't that fixed by 3247709 ?

tulir commented 1 year ago

That usually happens if homeserver -> public_address is misconfigured

Aeris1One commented 1 year ago

You're right, ansible playbook was not updated to add public_address config, thanks à lot ! Do you know why even when setting http(s)://my.domain or http(s)://matrix.my.domain message are sent but with a blank avatar ? EDIT: nevermind, was due to discord's caching