From c748c7c188c0c6343685b32e2807ce1e612aac86 Mon Sep 17 00:00:00 2001 From: Olivia Lee Date: Mon, 20 Jan 2025 12:04:14 -0800 Subject: [PATCH] return M_BAD_ALIAS when trying to set non-existent canonical aliases This is the error code named in the spec. --- book/changelog.md | 5 +++++ src/api/client_server/state.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/book/changelog.md b/book/changelog.md index 70af61f4..6dfe833b 100644 --- a/book/changelog.md +++ b/book/changelog.md @@ -220,6 +220,11 @@ This will be the first release of Grapevine since it was forked from Conduit so this situation is common. ([!55](https://gitlab.computer.surgery/matrix/grapevine/-/merge_requests/55)) ([!153](https://gitlab.computer.surgery/matrix/grapevine/-/merge_requests/153)) +25. Return 400 M_BAD_ALIAS from + [PUT /_matrix/client/v3/rooms/{roomId}/state/{eventType}/{stateKey}](https://spec.matrix.org/latest/client-server-api/#put_matrixclientv3roomsroomidstateeventtypestatekey) + instead of 400 M_FORBIDDEN when trying to set a canonical alias that does + not exist. + ([!158](https://gitlab.computer.surgery/matrix/grapevine/-/merge_requests/158)) ### Added diff --git a/src/api/client_server/state.rs b/src/api/client_server/state.rs index b0e5809a..a9a6c0fc 100644 --- a/src/api/client_server/state.rs +++ b/src/api/client_server/state.rs @@ -232,7 +232,7 @@ async fn send_state_event_for_key_helper( .is_none() { return Err(Error::BadRequest( - ErrorKind::forbidden(), + ErrorKind::BadAlias, "You are only allowed to send canonical_alias events when \ it's aliases already exists", ));