# 在更新主题组件#2时出现“空字符串不是有效的JSON字符串”错误

**URL:** https://meta.discourse.org/t/an-empty-string-is-not-a-valid-json-string-when-updating-theme-component-2/321820
**Category:** Bug
**Tags:** custom-header-links, fixed
**Created:** [2024年八月15日 13:52 UTC](https://meta.discourse.org/t/an-empty-string-is-not-a-valid-json-string-when-updating-theme-component-2/321820 "2024-08-15T13:52:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2024年八月15日 13:52 UTC](https://meta.discourse.org/t/an-empty-string-is-not-a-valid-json-string-when-updating-theme-component-2/321820/1 "2024-08-15T13:52:40Z")

</div>

与[此问题](https://meta.discourse.org/t/an-empty-string-is-not-a-valid-json-string-when-updating-theme-component/319476)相同，但这次是针对 [Custom Header Links](https://meta.discourse.org/t/custom-header-links/90588)

也许这在服务器端处理更好，而不是在各个主题组件中修复？

```plaintext
lib/theme_settings_manager/objects.rb:13:in `parse'
lib/theme_settings_manager/objects.rb:13:in `value='
app/models/theme.rb:760:in `update_setting'
app/models/theme.rb:881:in `block (2 levels) in migrate_settings'
app/models/theme.rb:880:in `each'
app/models/theme.rb:880:in `block in migrate_settings'
app/models/theme.rb:919:in `migrate_settings'
app/models/remote_theme.rb:377:in `block in update_from_remote'

```

---

<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: [2024年八月26日 02:01 UTC](https://meta.discourse.org/t/an-empty-string-is-not-a-valid-json-string-when-updating-theme-component-2/321820/4 "2024-08-26T02:01:10Z")

</div>

将在以下位置修复：

> <https://github.com/discourse/discourse-custom-header-links/pull/69>
>
> If the old theme setting value is set to a blank string, we will end up not migr…ating it and thus cause an error to be raised.

> [@RGJ](#):
>
> 也许这在服务器端处理会更好，而不是在各个主题组件中修复？

我现在不确定这一点，并希望看到更多失败的例子后再做决定。

感谢您在此报告错误 👍

---

<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: [2024年八月26日 22:45 UTC](https://meta.discourse.org/t/an-empty-string-is-not-a-valid-json-string-when-updating-theme-component-2/321820/6 "2024-08-26T22:45:34Z")

</div>


