# 空字符串作为投票会导致崩溃

**URL:** <https://meta.discourse.org/t/empty-string-as-a-vote-causes-crash/94338>\
**Category:** Bug\
**Tags:** topic-voting\
**Created:** [2018年八月9日 18:30 UTC](https://meta.discourse.org/t/empty-string-as-a-vote-causes-crash/94338 "2018-08-09T18:30:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yanokwa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yanokwa/32/105083_2.png) [@yanokwa](https://meta.discourse.org/u/yanokwa)\
**Post date:** [2018年八月9日 18:30 UTC](https://meta.discourse.org/t/empty-string-as-a-vote-causes-crash/94338/1 "2018-08-09T18:30:09Z")

</div>

When I enable the voting plugin on my Discourse plugin, I get this crash when I log in.

 ![22](https://global.discourse-cdn.com/meta/original/3X/f/0/f08bcc9439bb48468695aa1e1725a94899d5e766.png)

I’ve run the below query in [data explorer](https://meta.discourse.org/t/32566?silent=true) and I see a handful of users with empty values.

```plaintext
SELECT * FROM user_custom_fields WHERE name = 'votes' AND value = ''

```

I have this [pull request](https://github.com/discourse/discourse-voting/pull/33/commits/684a85f7c8e31be54dc98c5a55d40d6d896d99bc) merged, but I’m still seeing the above crash.

I know very little about Ruby and Rails, so I guess my ask is, should the PR have fixed the issue? If not, any guidance on what I could do to fix it. I kinda like the voting plugin 🙂

---

<div class="post-metadata">

**Author:** ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)\
**Post date:** [2018年八月9日 19:03 UTC](https://meta.discourse.org/t/empty-string-as-a-vote-causes-crash/94338/2 "2018-08-09T19:03:24Z")

</div>

Sorry about that - the issue here is that somehow users’ custom fields are being loaded as an empty string, not as an array. Can you try this fix? 🍏

[https://github.com/discourse/discourse-voting/commit/85f39aff810f53bef92bb9319b6363b062567551](https://github.com/discourse/discourse-voting/commit/85f39aff810f53bef92bb9319b6363b062567551)

Were some users merged, perchance?

---

<div class="post-metadata">

**Author:** ![yanokwa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yanokwa/32/105083_2.png) [@yanokwa](https://meta.discourse.org/u/yanokwa)\
**Post date:** [2018年八月9日 23:29 UTC](https://meta.discourse.org/t/empty-string-as-a-vote-causes-crash/94338/4 "2018-08-09T23:29:49Z")

</div>

Some users were merged, but they are not the ones that have empty values. Either way, the PR solves the problem!

---

<div class="post-metadata">

**Author:** ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)\
**Post date:** [2018年八月22日 20:42 UTC](https://meta.discourse.org/t/empty-string-as-a-vote-causes-crash/94338/5 "2018-08-22T20:42:00Z")

</div>


