404 error when you revert a tag name after changing it without reloading the page

This is a very minor bug, sort of an edge case, but hitting a 404 is never pleasant as it triggers a “did I do something wrong?” when managing a website.

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.

tag 404)

tag 404

If you change a tag name at least once and end up choosing any tag name you previously validated on the same screen (or the original name), Discourses requests a wrong /tag/<tag_name>/notifications route using an unused tag_name, which results in a 404 error.

Reproduction steps:

  1. Open an existing tag page: https://your-discourse.com/tag/a

  2. Click the wrench, change the name and validate :white_check_mark:

  3. (optional) change the name again

  4. Revert the name to one of the previous ones (or the original tag name)

  5. :four: :zero: :four: