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

pr-welcome

#1

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.


(aki) #2

hi can i work on this.


(Sam Saffron) #3

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


(aki) #4

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 .


#5

@aki, the API point to create a topic is documented here. To set tags, use the undocumented additional parameter tags, which is an array of strings.


(aki) #6

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


#7

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:

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

So maybe in our case we should have this:

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

#8

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.


(aki) #9

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


(Erlend Sogge Heggen) #10

Have you submitted a pull request for this?


(aki) #11

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


#12

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


(Erlend Sogge Heggen) #13

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, and there’s plenty of other ones (including interactive tutorials) just a search away.