Username removed when updating the user
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
- [x] Read the Contributing Guidelines.
- [x] Check that there isn't already an issue that reports the same bug.
- [x] Check that this is a concrete bug. For Q&A, open a GitHub Discussion.
- [x] The provided reproduction is a minimal reproducible example of the bug.
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
Fixed in #171 and #173
Addressed @Hajbo's point about PATCH vs PUT in #172