diff --git a/changelog.d/2451.bugfix.1.md b/changelog.d/2451.bugfix.1.md new file mode 100644 index 000000000..c102c6bd5 --- /dev/null +++ b/changelog.d/2451.bugfix.1.md @@ -0,0 +1 @@ +Setting a profile key longer than 255 bytes now returns 400 `M_KEY_TOO_LARGE` as required by the spec, instead of 413 `M_TOO_LARGE`. diff --git a/src/service/users/profile.rs b/src/service/users/profile.rs index 954b0eac4..b2c0c3e3b 100644 --- a/src/service/users/profile.rs +++ b/src/service/users/profile.rs @@ -51,12 +51,8 @@ impl super::Service { let field_name = change.field_name(); - // TODO: The spec mentions special error codes (M_PROFILE_TOO_LARGE, - // M_KEY_TOO_LARGE) for profile field size limits, but they're not in - // its list of error codes and Ruma doesn't have them. Should we - // return those, or is M_TOO_LARGE okay? if field_name.as_str().len() > MAX_KEY_LENGTH_BYTES { - return Err!(Request(TooLarge( + return Err!(Request(KeyTooLarge( "Individual profile keys must not exceed {MAX_KEY_LENGTH_BYTES} bytes in length." ))); }