From 4d0ccd998fd0e8b4eb3fe22359f9c02453cc7711 Mon Sep 17 00:00:00 2001 From: Bardi Harborow Date: Wed, 4 Nov 2026 21:26:16 +1100 Subject: [PATCH] fix: Return M_PROFILE_TOO_LARGE for oversize profiles Profile updates that would push the profile over 64 KiB were rejected with an untyped error, producing a 500. The spec requires 400 M_PROFILE_TOO_LARGE, which ruma now provides. --- changelog.d/2451.bugfix.2.md | 1 + src/service/users/profile.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changelog.d/2451.bugfix.2.md diff --git a/changelog.d/2451.bugfix.2.md b/changelog.d/2451.bugfix.2.md new file mode 100644 index 000000000..49cf46a52 --- /dev/null +++ b/changelog.d/2451.bugfix.2.md @@ -0,0 +1 @@ +Setting profile data that would make the profile exceed 64 KiB now returns 400 `M_PROFILE_TOO_LARGE` as required by the spec, instead of a 500 error. diff --git a/src/service/users/profile.rs b/src/service/users/profile.rs index b2c0c3e3b..cad67765c 100644 --- a/src/service/users/profile.rs +++ b/src/service/users/profile.rs @@ -80,10 +80,10 @@ impl super::Service { .len() > MAX_PROFILE_LENGTH_BYTES { - return Err!( + return Err!(Request(ProfileTooLarge( "Profile data must not exceed {MAX_PROFILE_LENGTH_BYTES} bytes in \ length." - ); + ))); } } else { return Err!(Request(BadJson("Failed to canonicalize profile.")));