# \[API\] data loss caused by changed behaviour of custom user\_field update

**URL:** https://meta.discourse.org/t/api-data-loss-caused-by-changed-behaviour-of-custom-user-field-update/74990
**Category:** Bug
**Created:** [29 نوفمبر 2017، 1:46ص UTC](https://meta.discourse.org/t/api-data-loss-caused-by-changed-behaviour-of-custom-user-field-update/74990 "2017-11-29T01:46:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![PhALDan.test](https://avatars.discourse-cdn.com/v4/letter/p/4bbf92/32.png) [@PhALDan.test](https://meta.discourse.org/u/PhALDan.test)
#### Post date: [29 نوفمبر 2017، 1:46ص UTC](https://meta.discourse.org/t/api-data-loss-caused-by-changed-behaviour-of-custom-user-field-update/74990/1 "2017-11-29T01:46:54Z")

</div>

For example I have configured two custom user\_fields: `1` and `2`  
Executing the following request to update custom user\_field `2` clears the content of the custom user\_field `1`:  
`curl -X PUT -d 'user_fields[2]=Lorem ipsum' http://discourse.example.com/users/john-doe.json?api_key=test_d7fd0429940&api_username=test_user`

In the past this request only changed the content of custom user\_field `2` and the content of custom user\_field `1` was unchanged.

Was this change of the custom user\_fields update intentional?  
Tested with Discourse version 1.8.10

---

<div class="post-metadata">

### Author: ![PhALDan.test](https://avatars.discourse-cdn.com/v4/letter/p/4bbf92/32.png) [@PhALDan.test](https://meta.discourse.org/u/PhALDan.test)
#### Post date: [16 ديسمبر 2017، 2:37ص UTC](https://meta.discourse.org/t/api-data-loss-caused-by-changed-behaviour-of-custom-user-field-update/74990/2 "2017-12-16T02:37:32Z")

</div>

Added pull request with tests for this bug: [Proof-of-concept: Data loss on update of single user\_field by phaldan · Pull Request #5438 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/5438)

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [20 ديسمبر 2017، 8:35ص UTC](https://meta.discourse.org/t/api-data-loss-caused-by-changed-behaviour-of-custom-user-field-update/74990/3 "2017-12-20T08:35:47Z")

</div>

Fixed in

[https://github.com/discourse/discourse/commit/6a2bce19317b05f1eab56f82ced58a248db90d94](https://github.com/discourse/discourse/commit/6a2bce19317b05f1eab56f82ced58a248db90d94)

Thank you @PhALDan.test for providing the test case.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [25 ديسمبر 2017، 10:00ص UTC](https://meta.discourse.org/t/api-data-loss-caused-by-changed-behaviour-of-custom-user-field-update/74990/4 "2017-12-25T10:00:07Z")

</div>

This topic was automatically closed after 5 days. New replies are no longer allowed.
