From 5f9e85cb49b95ff8b3af0e513cf40f77c5cf1b2b Mon Sep 17 00:00:00 2001 From: Olivia Lee Date: Sun, 18 May 2025 13:30:42 -0700 Subject: [PATCH] return an error when attempting to delete a nonexistent local alias The spec doesn't spell out explicitly that the server should check this, but it does list M_NOT_FOUND "room alias ... not found" as an example error response. --- book/changelog.md | 2 ++ src/api/client_server/alias.rs | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/book/changelog.md b/book/changelog.md index 3f12e7d0..d552c3fa 100644 --- a/book/changelog.md +++ b/book/changelog.md @@ -153,6 +153,8 @@ This will be the first release of Grapevine since it was forked from Conduit 14. Use trust-dns for all DNS queries, instead of only for SRV records and SRV record targets in server discovery. ([!156](https://gitlab.computer.surgery/matrix/grapevine/-/merge_requests/156)) +15. Return an error on when attempting to delete a nonexistent local alias. + ([!186](https://gitlab.computer.surgery/matrix/grapevine/-/merge_requests/186)) ### Fixed diff --git a/src/api/client_server/alias.rs b/src/api/client_server/alias.rs index b2fbcf65..5ec165f5 100644 --- a/src/api/client_server/alias.rs +++ b/src/api/client_server/alias.rs @@ -75,6 +75,13 @@ pub(crate) async fn delete_alias_route( )); } + if services().rooms.alias.resolve_local_alias(&body.room_alias)?.is_none() { + return Err(Error::BadRequest( + ErrorKind::NotFound, + "Alias is not assigned.", + )); + } + if let Some(info) = &body.appservice_info { if !info.aliases.is_match(body.room_alias.as_str()) { return Err(Error::BadRequest(