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

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.

4 Me gusta

hi can i work on this.

2 Me gusta

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

6 Me gusta

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 .

1 me gusta

@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.

1 me gusta

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

1 me gusta

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' ]
  }
}
2 Me gusta

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.

2 Me gusta

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

1 me gusta

Have you submitted a pull request for this?

4 Me gusta

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

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

6 Me gusta

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.

4 Me gusta

He creado una PR para mejorar la API aquí, de modo que ahora se devuelve un error 422 al intentar etiquetar un tema cuando no tienes permiso para hacerlo.

https://github.com/discourse/discourse/pull/10400

5 Me gusta