# 在不刷新页面的情况下更改标签名称后再还原时出现404错误

**URL:** <https://meta.discourse.org/t/404-error-when-you-revert-a-tag-name-after-changing-it-without-reloading-the-page/342559>\
**Category:** Bug\
**Tags:** tags\
**Created:** [2024年十二月15日 19:49 UTC](https://meta.discourse.org/t/404-error-when-you-revert-a-tag-name-after-changing-it-without-reloading-the-page/342559 "2024-12-15T19:49:48Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)\
**Post date:** [2025年一月29日 02:36 UTC](https://meta.discourse.org/t/404-error-when-you-revert-a-tag-name-after-changing-it-without-reloading-the-page/342559/6 "2025-01-29T02:36:18Z")

</div>

感谢您提供的详细报告，我已经找到了修复方法，并将很快合并：

> <https://github.com/discourse/discourse/pull/31049>
>
> Changing a tag name and reverting it to a previous tag name choice on
> the same …screen (meaning, without reloading the page) causes a 404
> error.
> 
> Reproduction steps:
> 
> \* Open an existing tag page https://your-discourse.com/tag/a
> \* Click the wrench, change the name and save
> \* Open edit again, revert the name to the original tag name
> \* 404 error
> 
> This was happening because of the way we find existing objects
> in our store. Tags are using the name as the id/primary key
> unlike other records in the UI. When we get the existing object
> from the store we throw away the "new" ID, so we ended up with
> the old tag ID on the existing object, which led to a 404. To
> fix it we can just manually set the tag ID to what it is supposed
> to be from params in the tag show route.
> 
> c.f. https://meta.discourse.org/t/404-error-when-you-revert-a-tag-name-after-changing-it-without-reloading-the-page/342559

---

_[View the full topic](https://meta.discourse.org/t/404-error-when-you-revert-a-tag-name-after-changing-it-without-reloading-the-page/342559)._
