{"action":"reopened","issue":{"url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/177","labels_url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/177/labels{/name}","comments_url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/177/comments","events_url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/177/events","html_url":"https://github.com/stormpath/stormpath-sdk-node/issues/177","id":101515429,"number":177,"title":"customData.save fails when removing last key","user":{"login":"tuck182","id":747586,"avatar_url":"https://avatars.githubusercontent.com/u/747586?v=3","gravatar_id":"","url":"https://api.github.com/users/tuck182","html_url":"https://github.com/tuck182","followers_url":"https://api.github.com/users/tuck182/followers","following_url":"https://api.github.com/users/tuck182/following{/other_user}","gists_url":"https://api.github.com/users/tuck182/gists{/gist_id}","starred_url":"https://api.github.com/users/tuck182/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuck182/subscriptions","organizations_url":"https://api.github.com/users/tuck182/orgs","repos_url":"https://api.github.com/users/tuck182/repos","events_url":"https://api.github.com/users/tuck182/events{/privacy}","received_events_url":"https://api.github.com/users/tuck182/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-08-17T21:37:53Z","updated_at":"2015-09-01T18:46:36Z","closed_at":null,"body":"We're seeing error where, when removing a key from customData and saving:\r\n\r\n```\r\n      req.user.customData.remove('key-to-remove');\r\n      req.user.customData.save(function (err) {\r\n        if (err) {\r\n          return next(err);\r\n        }\r\n        . . . do stuff . . .\r\n      });\r\n```\r\n\r\nif the key being removed is the LAST key in the customData object, we get the following error:\r\n\r\n```\r\n21:33:01.139Z ERROR main: HTTP 400, Stormpath 2000 (http://docs.stormpath.com/errors/2000): CustomData properties cannot be null, empty, or blank. (err.code=2000)\r\n```\r\n\r\nThis is fairly easy to test by creating a user with a single key/value in customData, then using remove/save to remove it.\r\n\r\nGiven that the customData object can be empty, it should be possible to remove the last key and have it result in being empty. It seems like it might be possible to check whether there are no keys remaining and then use `customData.remove` instead, but a) there doesn't seem to be a good way to do this and b) it doesn't really feel like this sort of check should be necessary."}}