Do not fail the entire transaction for a single bad PDU

This commit is contained in:
Kegan Dougal 2025-08-13 13:42:06 +01:00
parent 1fa4e4127a
commit 18ef97687d

View file

@ -134,6 +134,8 @@ func (t *TxnReq) ProcessTransaction(ctx context.Context) (*fclient.RespSend, *ut
} }
event, err := verImpl.NewEventFromUntrustedJSON(pdu) event, err := verImpl.NewEventFromUntrustedJSON(pdu)
if err != nil { if err != nil {
/* Do not reject the entire transaction for a single bad PDU, that's dumb.
if _, ok := err.(gomatrixserverlib.BadJSONError); ok { if _, ok := err.(gomatrixserverlib.BadJSONError); ok {
// Room version 6 states that homeservers should strictly enforce canonical JSON // Room version 6 states that homeservers should strictly enforce canonical JSON
// on PDUs. // on PDUs.
@ -146,7 +148,7 @@ func (t *TxnReq) ProcessTransaction(ctx context.Context) (*fclient.RespSend, *ut
Code: 400, Code: 400,
JSON: spec.BadJSON("PDU contains bad JSON"), JSON: spec.BadJSON("PDU contains bad JSON"),
} }
} } */
util.GetLogger(ctx).WithError(err).Debugf("Transaction: Failed to parse event JSON of event %s", string(pdu)) util.GetLogger(ctx).WithError(err).Debugf("Transaction: Failed to parse event JSON of event %s", string(pdu))
continue continue
} }