Tag upload with special characters via CSV is failing

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

Message (8 copies reported)

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


/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord- `raise_validation_error'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord- `save!'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord- `block in save!'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord- `block in with_transaction_returning_status'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord- `transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord- `transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord- `with_transaction_returning_status'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord- `save!'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord- `save!'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord- `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!

1 Like

Can we repro this Monday @tshenry?


Thank you @codinghorror - do let me know if you find anything. If it helps, I am running 2.5.0.beta7 ( 14dc6f350e ) on a Droplet with 4 GB RAM and 80 GB SSD.

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

I just tested this out on 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 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)?

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.

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 )

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

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 :slight_smile:

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

1 Like

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.

1 Like

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

$ vi tags-1.csv

i to enter edit mode
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.

1 Like

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 :man_shrugging:


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

1 Like

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.

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.

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.

1 Like

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 (A comprehensive guide to Discourse tags)


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.