SSO 500 Error: Failed to create or lookup user: no implicit conversion of Array into String

There are two problems here:

  1. Accessing a plugin custom fields may return a String or an Array and there isn’t any protection for plugin authors here. If I do user_custom_fields["date_of_birth"] = "2016-05-02" I should ideally always get back a String if I retrieve the custom fields again. Currently, accessing custom fields may return an Array if custom fields with the same name and user_id is somehow set around the same time. This is not ideal IMO as either all access to a plugin custom fields will have to be accompanied by a check to see if it is an Array or String or a lock has to be used when setting any custom field.

  2. Maintaining a valid date as a String is not ideal. Initially when I started working on the plugin, we decided to store the date in a UserCustomField instead of User#date_of_birth because the requirements for the plugin was simple and we can get away with it even if the date_of_birth is invalid. Right now, we use the date of birth field in more places and an invalid format will just blow things up. I’ll look to see if I can migrate custom fields into User#date_of_birth to ensure consistency in the date format.

3 Likes