the-bed-stack icon indicating copy to clipboard operation
the-bed-stack copied to clipboard

Username removed when updating the user

Open aruaycodes opened this issue 9 months ago • 1 comments

Describe the bug

When trying out the user update, the username gets removed

Reproduction

curl http://localhost:3000/api/user
--request PUT
--header 'Content-Type: application/json'
--header 'Authorization: Token ey...'
--data '{ "user": { "email": "", "bio": "", "image": "", "password": "", "username": "" } }'

System Info

No response

Validations

aruaycodes avatar Mar 22 '25 05:03 aruaycodes

If the empty username was sent in the request, then it will be overwritten to an empty string (this is a good point, a validation for min length should be there for the username, password and email fields).

Otherwise this behaviour is expected, the provided fields will be updated, while others stay untouched. This endpoint acts like a HTTP PATCH, but for some reason the documentation requires a PUT. This is the official implementation

Hajbo avatar Mar 24 '25 14:03 Hajbo

Fixed in #171 and #173

Addressed @Hajbo's point about PATCH vs PUT in #172

yamcodes avatar Jun 11 '25 07:06 yamcodes