# Tag upload with special characters via CSV is failing

**URL:** https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821
**Category:** Support
**Created:** [14 juni 2020 om 17:34 UTC](https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821 "2020-06-14T17:34:42Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![krishraov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/krishraov/32/138744_2.png) [@krishraov](https://meta.discourse.org/u/krishraov)
#### Post date: [14 juni 2020 om 17:34 UTC](https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821/1 "2020-06-14T17:34:42Z")

</div>

Hi - I am trying to upload a CSV file with a bunch of tags in them and each time I get an error message that says “Sorry, there was an error uploading that file. Please try again.”

The logs in the admin panel says

```plaintext
Message (8 copies reported)

Failed to process hijacked response correctly : Validation failed: Name is invalid

Backtrace

/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/validations.rb:80:in `raise_validation_error'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/validations.rb:53:in `save!'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:318:in `block in save!'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/database_statements.rb:278:in `transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:212:in `transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:318:in `save!'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/suppressor.rb:48:in `save!'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/persistence.rb:55:in `create!'

```

I tried creating a dummy tag i.e., just one entry in the CSV file (i.e, the word java) and I get the same error message.

FYI, I installed Discourse on DigitalOcean using the official installation guide and everything else is running fine.

Thank you!

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [14 juni 2020 om 18:59 UTC](https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821/2 "2020-06-14T18:59:57Z")

</div>

Can we repro this Monday @tshenry?

---

<div class="post-metadata">

### Author: ![krishraov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/krishraov/32/138744_2.png) [@krishraov](https://meta.discourse.org/u/krishraov)
#### Post date: [15 juni 2020 om 02:39 UTC](https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821/3 "2020-06-15T02:39:27Z")

</div>

Thank you @codinghorror - do let me know if you find anything. If it helps, I am running 2.5.0.beta7 ( [14dc6f350e](https://github.com/discourse/discourse/commits/14dc6f350ed9b50755ba25c270012380d19a9603)) on a Droplet with 4 GB RAM and 80 GB SSD.

Apart from this, I’ve installed the aksimet, formatting-toolbar, discourse-voting plugins.

---

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [15 juni 2020 om 16:37 UTC](https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821/4 "2020-06-15T16:37:57Z")

</div>

I just tested this out on [try.discourse.org](http://try.discourse.org). I used a basic text editor to create a CSV file called `tags.csv` with nothing but the word `java` in it and was able to use the bulk tag uploading tool to add the new tag without issue.

The [try.discourse.org](http://try.discourse.org) site has akismet and discourse-voting, and I highly doubt the formatting-toolbar plugin would conflict in any way that would produce the error you are seeing.

Are you able to upload files without issue in other contexts (posts, themes, etc)?

---

<div class="post-metadata">

### Author: ![krishraov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/krishraov/32/138744_2.png) [@krishraov](https://meta.discourse.org/u/krishraov)
#### Post date: [15 juni 2020 om 16:42 UTC](https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821/5 "2020-06-15T16:42:34Z")

</div>

Hi @tshenry - yes, I am able to upload images in posts that I make if that is what you are asking.

I destroyed the droplet and re-installed Discourse and I am using only following plugins.

 ![Screenshot 2020-06-15 at 10.10.36 PM](https://global.discourse-cdn.com/meta/original/3X/d/f/dfc5f6a4564689b9e44c3b291c7627fba5b2b37a.png)

The upload still fails. Is it anything to do with permissions? I am the admin of the site so I suppose I should have all the permissions to do this.

This time, I am using 2.5.0.beta7 ( [70e50a2255](https://github.com/discourse/discourse/commits/70e50a2255ebb30c78891a7f846e833ab85b0a8b))

Let me know if there is anything else you’d like me to try. Thanks!

---

<div class="post-metadata">

### Author: ![krishraov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/krishraov/32/138744_2.png) [@krishraov](https://meta.discourse.org/u/krishraov)
#### Post date: [15 juni 2020 om 16:46 UTC](https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821/6 "2020-06-15T16:46:14Z")

</div>

Ah - I found something interesting @codinghorror @tshenry.

If the tags file is named `tags-1.csv` then I get an upload error. If I name the file `tags.csv`, then the tag upload succeeds 🙂

Is this nomenclature something that Discourse needs (and I missed reading about), or perhaps its a bug?

---

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [15 juni 2020 om 16:56 UTC](https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821/7 "2020-06-15T16:56:04Z")

</div>

Hmm, I tried renaming my file to `tags-1.csv` and still couldn’t reproduce the error. If you change it back to `tags-1.csv` and try uploading, does it fail again? I’m wondering if there was something else going on in your original filename and changing it to `tags.csv` somehow fixed it.

---

<div class="post-metadata">

### Author: ![krishraov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/krishraov/32/138744_2.png) [@krishraov](https://meta.discourse.org/u/krishraov)
#### Post date: [15 juni 2020 om 17:02 UTC](https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821/8 "2020-06-15T17:02:25Z")

</div>

Nope still doesn’t work for me. All I am doing on my Mac is

```
$ vi tags-1.csv

```

Then  
`i` to enter edit mode  
`java`  
`esc` to exit edit mode  
`:wq` and Enter to save and exit.

That’s it. This too fails. I initially thought it might have something to do with an Excel being exported to CSV, but, even commandline editing is throwing issues.

I’ll continue for now with `tags.csv`, but, if you think this is important and would like me to run tests, I’ll be glad to. The same thing happened on two different droplets with fresh installs which worried me.

Thanks @tshenry.

---

<div class="post-metadata">

### Author: ![krishraov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/krishraov/32/138744_2.png) [@krishraov](https://meta.discourse.org/u/krishraov)
#### Post date: [15 juni 2020 om 17:16 UTC](https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821/9 "2020-06-15T17:16:49Z")

</div>

I see another issue (again, not sure if this is related to my environment).

My tags are a list of programming languages. I had c++ and c# in that list and once I removed them out of tags.csv, the bulk upload passed. I wonder if this has something to do with the tag ending with a special character. Again might just be me 🤷‍♂️

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [15 juni 2020 om 17:18 UTC](https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821/10 "2020-06-15T17:18:51Z")

</div>

That is almost certainly the issue. I wonder if we can return a better error here for invalid tags?

---

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [15 juni 2020 om 17:33 UTC](https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821/11 "2020-06-15T17:33:43Z")

</div>

Yes! That is definitely the issue. I was thinking we were only working with the word `java` in the file given your last post. You would need to use something like cpp, c-sharp, etc.

> [@codinghorror](#):
>
> I wonder if we can return a better error here for invalid tags?

Yeah, I think that would be ideal. The current error doesn’t really give the user much to go on:

> Sorry, there was an error uploading that file. Please try again.

Interesting note I wasn’t aware of - when trying to create a tag in normal topic creation/editing contexts, it looks like we just quietly strip out any symbols. So entering `C++` would suggest `C` as the tag.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [15 juni 2020 om 17:39 UTC](https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821/12 "2020-06-15T17:39:53Z")

</div>

I was going to edit the copy (to indicate the possibility of invalid tags), but I think that copy applies to all uploads so it wouldn’t always be accurate.

---

<div class="post-metadata">

### Author: ![krishraov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/krishraov/32/138744_2.png) [@krishraov](https://meta.discourse.org/u/krishraov)
#### Post date: [15 juni 2020 om 17:42 UTC](https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821/13 "2020-06-15T17:42:28Z")

</div>

> [@tshenry](#):
>
> Sorry, there was an error uploading that file. Please try again.

A quick way IMO would be to put a couple of sentences on this in the Tags section of the Admin Settings describing the restrictions around tag names.

And, perhaps a warning in the Discourse Tags guide ([Admin guide to tags in Discourse](https://meta.discourse.org/t/a-comprehensive-guide-to-discourse-tags/121041))

---

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [15 juni 2020 om 17:44 UTC](https://meta.discourse.org/t/tag-upload-with-special-characters-via-csv-is-failing/154821/14 "2020-06-15T17:44:43Z")

</div>

Yeah, that definitely seems to be the case. I found where the generic error gets thrown in the tag upload code, so I’ll take a stab at creating a more specific error for this case in a PR.
