# \[API\] Creating a topic with a new tag without tag-creation permission fails silently

**URL:** https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525
**Category:** Bug
**Tags:** rest-api
**Created:** [9월 21, 2017, 4:50오후 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525 "2017-09-21T16:50:05Z")
**Posts on this page:** 15
**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: [9월 21, 2017, 4:50오후 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525/1 "2017-09-21T16:50:05Z")

</div>

When using the API to create a topic that contains a new tag, if the user identified by `api_username` cannot create tags, the query creates the topic but silently fails to add the tag.

EDIT - Additional issue: when using the API to create a topic that contains a new tag, if the Discourse instance has the “tags” feature turned off, the query creates the topic but silently fails to add the tag.

---

<div class="post-metadata">

### Author: ![aki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aki/32/142770_2.png) [@aki](https://meta.discourse.org/u/aki)
#### Post date: [9월 23, 2017, 9:02오전 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525/2 "2017-09-23T09:02:09Z")

</div>

hi can i work on this.

---

<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: [9월 25, 2017, 7:00오전 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525/3 "2017-09-25T07:00:31Z")

</div>

I support improving the API here to properly return an error vs silently dropping the tags. #pr-welcome

---

<div class="post-metadata">

### Author: ![aki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aki/32/142770_2.png) [@aki](https://meta.discourse.org/u/aki)
#### Post date: [10월 9, 2017, 10:25오전 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525/4 "2017-10-09T10:25:58Z")

</div>

hi sorry for being late can you please direct me how to proceed and where to find this issue. i tried creating topic but not able find any option to add tag in it .

---

<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: [10월 9, 2017, 1:52오후 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525/5 "2017-10-09T13:52:42Z")

</div>

@aki, the API point to create a topic is documented [here](http://docs.discourse.org/#tag/Topics%2Fpaths%2F~1posts%2Fpost). To set tags, use the undocumented additional parameter `tags`, which is an array of strings.

---

<div class="post-metadata">

### Author: ![aki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aki/32/142770_2.png) [@aki](https://meta.discourse.org/u/aki)
#### Post date: [10월 10, 2017, 6:54오후 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525/6 "2017-10-10T18:54:37Z")

</div>

Thanks @jack2 what should be displayed in error message. topic should be allowed to create without tag in that case or not?

---

<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: [10월 10, 2017, 9:57오후 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525/7 "2017-10-10T21:57:59Z")

</div>

I think topic creation should fail if tag(s) cannot be created.

Here is the response I get when trying to create a topic with an invalid title:

```test
{ 
  statusCode: 422,
  data: {
    action: 'create_post',
    errors: ['Title has already been used'] 
  }
}

```

So maybe in our case we should have this:

```test
{ 
  statusCode: 422,
  data: {
    action: 'create_post',
    errors: ['Tag creation not allowed']
  }
}

```

---

<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: [10월 10, 2017, 10:00오후 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525/8 "2017-10-10T22:00:28Z")

</div>

Notice that the issue described in this thread also occurs when creating a tagged topic with the tag feature turned off. I will edit my first post to reflect that.

---

<div class="post-metadata">

### Author: ![aki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aki/32/142770_2.png) [@aki](https://meta.discourse.org/u/aki)
#### Post date: [11월 8, 2017, 11:24오전 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525/9 "2017-11-08T11:24:53Z")

</div>

hi @jack2  
i have solve this bug trying to push my code and getting permission denied error.

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [12월 4, 2017, 11:07오전 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525/10 "2017-12-04T11:07:48Z")

</div>

> [@aki](#):
>
> i have solve this bug trying to push my code and getting permission denied error.

Have you submitted a pull request for this?

---

<div class="post-metadata">

### Author: ![aki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aki/32/142770_2.png) [@aki](https://meta.discourse.org/u/aki)
#### Post date: [12월 9, 2017, 7:16오후 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525/11 "2017-12-09T19:16:15Z")

</div>

hi @erlend_sh  
i am trying to push my branch to github but i am getting permission denied error.

---

<div class="post-metadata">

### Author: ![xrav3nz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xrav3nz/32/76894_2.png) [@xrav3nz](https://meta.discourse.org/u/xrav3nz)
#### Post date: [12월 10, 2017, 1:46오후 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525/12 "2017-12-10T13:46:48Z")

</div>

Hey Aki, you’ll need to fork the Discourse repo and push your branch to the fork. Check out this part of the guide:

> [@Contributing to Discourse development](https://meta.discourse.org/t/contributing-to-discourse-development/3823/1):
>
> **7) Fork**
> 
> `git remote add mine git@github.com:<your user name>/discourse.git`
> 
> **8) Push to your remote**
> 
> `git push mine new_discourse_branch`

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [12월 11, 2017, 3:42오후 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525/13 "2017-12-11T15:42:08Z")

</div>

If you need any more guidance with this @aki just let us know where you’re stuck. Git can be a bit confusing at first!

Luckily there’s lots of tutorials around. [GitHub has a pretty good one](https://guides.github.com/activities/hello-world/), and there’s plenty of other ones (including interactive tutorials) just a search away.

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [8월 7, 2020, 8:16오후 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525/15 "2020-08-07T20:16:52Z")

</div>

권한이 없는 상태에서 주제를 태그하려고 할 때 422 에러가 반환되도록 API를 개선하기 위해 PR을 생성했습니다.

> <https://github.com/discourse/discourse/pull/10400>
>
> The UI prevents users from trying to create tags on topics when they
> don't have… permission, but if you are trying to add tags to a topic via
> the API and you don't have permission before this change it would
> silently succeed in creating the topic, but it wouldn't have any tags.
> 
> Now a 422 error will be returned with an error message when trying to
> create a topic with tags when tagging is disabled or you don't have
> enough trust level to add tags to a topic.
> 
> Bug report: https://meta.discourse.org/t/-/70525/14

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [8월 11, 2020, 3:55오전 UTC](https://meta.discourse.org/t/api-creating-a-topic-with-a-new-tag-without-tag-creation-permission-fails-silently/70525/16 "2020-08-11T03:55:13Z")

</div>


