Compare commits

..

4 commits

Author SHA1 Message Date
Tulir Asokan 325891fead
Apply suggestion from @richvdh
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
2026-02-24 15:21:54 +02:00
Tulir Asokan 8bb5138185 Make example responses match recommendations 2026-02-24 15:21:16 +02:00
Tulir Asokan aa3abad39a Adjust wording so the validation reads nicer 2026-02-24 15:19:46 +02:00
Tulir Asokan 521bf40761 Don't mandate specific error code 2026-02-24 15:17:07 +02:00
8 changed files with 23 additions and 29 deletions

View file

@ -1 +1 @@
Specified input validation for PDUs passed to and returned from federation membership endpoints. Specify validation for PDUs passed to and returned from federation membership endpoints.

View file

@ -38,8 +38,8 @@ paths:
transaction](/server-server-api/#transactions). transaction](/server-server-api/#transactions).
Servers MUST apply certain validation to ensure they don't accidentally sign non-invite Servers MUST apply certain validation to ensure they don't accidentally sign non-invite
events from a malicious server. The `M_MISSING_PARAM` error code is used to indicate one events from a malicious server. A specific error code is not mandated, but servers SHOULD
or more of the following: return `M_INVALID_PARAM` if:
* The invite event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events). * The invite event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events).
* The event type is not `m.room.member`. * The event type is not `m.room.member`.
@ -47,8 +47,9 @@ paths:
* The event sender is not a user ID on the origin server. * The event sender is not a user ID on the origin server.
* The `state_key` is not a user ID on the receiving server. * The `state_key` is not a user ID on the receiving server.
The `M_MISSING_PARAM` error code is also used to indicate one or more of the following The `invite_room_state` has additional validation, which servers MAY apply to room versions
problems in the `invite_room_state` field: 1 through 11 and SHOULD apply to all other room versions. As with the above errors, servers
SHOULD return `M_INVALID_PARAM` if:
* The `m.room.create` event is missing from `invite_room_state`. * The `m.room.create` event is missing from `invite_room_state`.
* One or more entries in `invite_room_state` are not formatted according * One or more entries in `invite_room_state` are not formatted according
@ -57,9 +58,6 @@ paths:
* One or more events does not reside in the same room as the invite. * One or more events does not reside in the same room as the invite.
Note: Some room versions may require calculating the room ID for an Note: Some room versions may require calculating the room ID for an
event rather than relying on the presence of `room_id`. event rather than relying on the presence of `room_id`.
Servers MAY apply the `invite_room_state` validation to room versions 1 through 11,
and SHOULD apply the validation to all other room versions.
operationId: sendInviteV1 operationId: sendInviteV1
security: security:
- signedRequest: [] - signedRequest: []
@ -107,8 +105,7 @@ paths:
MUST additionally be formatted according to the room version specification. MUST additionally be formatted according to the room version specification.
Servers might need to apply validation to the `invite_room_state` depending Servers might need to apply validation to the `invite_room_state` depending
on room version. See the `400 M_MISSING_PARAM` error definition for more on room version. See endpoint description for more information.
information.
Note that events have a different format depending on the room Note that events have a different format depending on the room
version - check the [room version specification](/rooms) for version - check the [room version specification](/rooms) for
@ -210,7 +207,7 @@ paths:
examples: examples:
response: response:
value: { value: {
"errcode": "M_MISSING_PARAM", "errcode": "M_INVALID_PARAM",
"error": "Create event not among invite state entries." "error": "Create event not among invite state entries."
} }
servers: servers:

View file

@ -42,8 +42,8 @@ paths:
transaction](/server-server-api/#transactions). transaction](/server-server-api/#transactions).
Servers MUST apply certain validation to ensure they don't accidentally sign non-invite Servers MUST apply certain validation to ensure they don't accidentally sign non-invite
events from a malicious server. The `M_MISSING_PARAM` error code is used to indicate one events from a malicious server. A specific error code is not mandated, but servers SHOULD
or more of the following: return `M_INVALID_PARAM` if:
* The invite event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events). * The invite event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events).
* The event type is not `m.room.member`. * The event type is not `m.room.member`.
@ -51,8 +51,9 @@ paths:
* The event sender is not a user ID on the origin server. * The event sender is not a user ID on the origin server.
* The `state_key` is not a user ID on the receiving server. * The `state_key` is not a user ID on the receiving server.
The `M_MISSING_PARAM` error code is also used to indicate one or more of the following The `invite_room_state` has additional validation, which servers MAY apply to room versions
problems in the `invite_room_state` field: 1 through 11 and SHOULD apply to all other room versions. As with the above errors, servers
SHOULD return `M_INVALID_PARAM` if:
* The `m.room.create` event is missing from `invite_room_state`. * The `m.room.create` event is missing from `invite_room_state`.
* One or more entries in `invite_room_state` are not formatted according * One or more entries in `invite_room_state` are not formatted according
@ -61,9 +62,6 @@ paths:
* One or more events does not reside in the same room as the invite. * One or more events does not reside in the same room as the invite.
Note: Some room versions may require calculating the room ID for an Note: Some room versions may require calculating the room ID for an
event rather than relying on the presence of `room_id`. event rather than relying on the presence of `room_id`.
Servers MAY apply the `invite_room_state` validation to room versions 1 through 11,
and SHOULD apply the validation to all other room versions.
operationId: sendInviteV2 operationId: sendInviteV2
security: security:
- signedRequest: [] - signedRequest: []
@ -108,8 +106,7 @@ paths:
MUST additionally be formatted according to the room version specification. MUST additionally be formatted according to the room version specification.
Servers might need to apply validation to the `invite_room_state` depending Servers might need to apply validation to the `invite_room_state` depending
on room version. See the `400 M_MISSING_PARAM` error definition for more on room version. See the endpoint description for more information.
information.
Note that events have a different format depending on the room Note that events have a different format depending on the room
version - check the [room version specification](/rooms) for version - check the [room version specification](/rooms) for
@ -178,8 +175,8 @@ paths:
The error should be passed through to clients so that they The error should be passed through to clients so that they
may give better feedback to users. may give better feedback to users.
If `M_MISSING_PARAM` is returned and the request is associated with a If `M_MISSING_PARAM` or `M_INVALID_PARAM` is returned and the request is associated
Client-Server API request, the Client-Server API request SHOULD fail with a Client-Server API request, the Client-Server API request SHOULD fail
with a 5xx error rather than being passed through. with a 5xx error rather than being passed through.
content: content:
application/json: application/json:

View file

@ -251,7 +251,7 @@ paths:
fields for a PDU.** fields for a PDU.**
The receiving server MUST apply certain validation before accepting the event. The receiving server MUST apply certain validation before accepting the event.
The `M_INVALID_PARAM` error code is used to indicate one or more of the following: A specific error code is not mandated, but servers SHOULD return `M_INVALID_PARAM` if:
* The join event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events). * The join event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events).
* The event type is not `m.room.member`. * The event type is not `m.room.member`.

View file

@ -40,7 +40,7 @@ paths:
fields for a PDU.** fields for a PDU.**
The receiving server MUST apply certain validation before accepting the event. The receiving server MUST apply certain validation before accepting the event.
The `M_INVALID_PARAM` error code is used to indicate one or more of the following: A specific error code is not mandated, but servers SHOULD return `M_INVALID_PARAM` if:
* The join event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events). * The join event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events).
* The event type is not `m.room.member`. * The event type is not `m.room.member`.
@ -256,8 +256,8 @@ paths:
The error should be passed through to clients so that they The error should be passed through to clients so that they
may give better feedback to users. may give better feedback to users.
If `M_MISSING_PARAM` is returned and the request is associated with a If `M_MISSING_PARAM` or `M_INVALID_PARAM` is returned and the request is associated
Client-Server API request, the Client-Server API request SHOULD fail with a Client-Server API request, the Client-Server API request SHOULD fail
with a 5xx error rather than being passed through. with a 5xx error rather than being passed through.
New in `v1.2`, the following error conditions might happen: New in `v1.2`, the following error conditions might happen:

View file

@ -217,7 +217,7 @@ paths:
fields for a PDU.** fields for a PDU.**
The receiving server MUST apply certain validation before accepting the event. The receiving server MUST apply certain validation before accepting the event.
The `M_INVALID_PARAM` error code is used to indicate one or more of the following: A specific error code is not mandated, but servers SHOULD return `M_INVALID_PARAM` if:
* The knock event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events). * The knock event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events).
* The event type is not `m.room.member`. * The event type is not `m.room.member`.

View file

@ -166,7 +166,7 @@ paths:
fields for a PDU.** fields for a PDU.**
The receiving server MUST apply certain validation before accepting the event. The receiving server MUST apply certain validation before accepting the event.
The `M_INVALID_PARAM` error code is used to indicate one or more of the following: A specific error code is not mandated, but servers SHOULD return `M_INVALID_PARAM` if:
* The leave event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events). * The leave event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events).
* The event type is not `m.room.member`. * The event type is not `m.room.member`.

View file

@ -40,7 +40,7 @@ paths:
fields for a PDU.** fields for a PDU.**
The receiving server MUST apply certain validation before accepting the event. The receiving server MUST apply certain validation before accepting the event.
The `M_INVALID_PARAM` error code is used to indicate one or more of the following: A specific error code is not mandated, but servers SHOULD return `M_INVALID_PARAM` if:
* The leave event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events). * The leave event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events).
* The event type is not `m.room.member`. * The event type is not `m.room.member`.