# \[API\] Inconsistent error message when deleting a tag

**URL:** https://meta.discourse.org/t/api-inconsistent-error-message-when-deleting-a-tag/70729
**Category:** Bug
**Created:** [September 25, 2017, 12:27pm UTC](https://meta.discourse.org/t/api-inconsistent-error-message-when-deleting-a-tag/70729 "2017-09-25T12:27:28Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [September 25, 2017, 12:27pm UTC](https://meta.discourse.org/t/api-inconsistent-error-message-when-deleting-a-tag/70729/1 "2017-09-25T12:27:28Z")

</div>

When trying to delete a **non-existent topic** with the API, I get this (somewhat) understandable error:

```plaintext
status=403
content={"errors":["You are not permitted to view the requested resource."], 
    "error_type":"invalid_access"}

```

When trying to delete a **non-existent tag** , I get this:

```plaintext
status=500 
content=NoMethodError in TagsController#destroy - 
    undefined method `destroy&#39; for nil:NilClass

```

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [September 26, 2017, 7:47am UTC](https://meta.discourse.org/t/api-inconsistent-error-message-when-deleting-a-tag/70729/2 "2017-09-26T07:47:56Z")

</div>

API can be better here, #pr-welcome for that.

---

<div class="post-metadata">

### Author: ![ecdemis123](https://avatars.discourse-cdn.com/v4/letter/e/b9bd4f/32.png) [@ecdemis123](https://meta.discourse.org/u/ecdemis123)
#### Post date: [September 29, 2017, 6:56pm UTC](https://meta.discourse.org/t/api-inconsistent-error-message-when-deleting-a-tag/70729/3 "2017-09-29T18:56:30Z")

</div>

I’ll take a stab at fixing this.

---

<div class="post-metadata">

### Author: ![ecdemis123](https://avatars.discourse-cdn.com/v4/letter/e/b9bd4f/32.png) [@ecdemis123](https://meta.discourse.org/u/ecdemis123)
#### Post date: [September 29, 2017, 9:41pm UTC](https://meta.discourse.org/t/api-inconsistent-error-message-when-deleting-a-tag/70729/4 "2017-09-29T21:41:07Z")

</div>

Link to my fix: [FIX: response error when deleting non-existent tags by ecdemis123 · Pull Request #5213 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/5213)

---

<div class="post-metadata">

### Author: ![coderberry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/coderberry/32/99652_2.png) [@coderberry](https://meta.discourse.org/u/coderberry)
#### Post date: [November 29, 2017, 4:04am UTC](https://meta.discourse.org/t/api-inconsistent-error-message-when-deleting-a-tag/70729/5 "2017-11-29T04:04:43Z")

</div>

^ PR has been merged on Oct 2 :allthethings:

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 29, 2017, 5:52am UTC](https://meta.discourse.org/t/api-inconsistent-error-message-when-deleting-a-tag/70729/6 "2017-11-29T05:52:06Z")

</div>


