Missing Category Causing Create Topic Failures

(Christopher Baker) #1

Hi there, first, thank you for an amazing project. It’s been a wonderful community catalyst for us.

First a few details about our setup:

  • We recently moved from the Ubuntu 12.04 to the docker setup (although I think this issue may have happened before). We upgraded by creating a backup in the admin panel and uploading it to our new clean docker install.
  • We are on Discourse 0.9.9
  • We are using a digital ocean 2 GB droplet with a 1 GB swap (just in case).
  • We are running Ubuntu 12.04.4 LTS.

Some of our users are encountering a strange issue when creating new topics. For instance, this user posted a new topic with a hyperlink and ended up seeing this:

He was no longer able to see his post, but I was. It was not assigned a valid category, but rather a junk category that I have been trying to delete.

When I give this user admin rights he can see it OR when I re-categorize it (I have admin rights), it becomes visible to all.

Other users encountering the same issue have gotten message post failures that read “500 error” in a small modal window (sorry no screen shot). Still others have gotten this just after hitting the “create topic”:

In this case, like the others, the user was unable to view the topic because it was categorized with a category that they were unable to see (he was not an admin). When I manually categorized it, everyone was able to see it.

Ultimately, from my sleuthing it seems to be some kind of problem related to a bogus category mixing with the permissions of the newer [Staff] category (we started using Discourse before that category was added).

Here are some other clues from my end.

  1. Sidekiq is choking on lots of category_id when sending email updates.

  2. I look at one of these failed posts and find it in the “staff” cateogory.

  3. I open the strange post.

  4. I check its category:

So my theory is that on occasion, when users are creating a new topic, this “Ghost” category (maybe it has a nil category id?) is being assigned to the topic (this happens even when the user manually selects a different category). Since this category is broken and has admin only security settings (not sure where to change that on a category I can’t see … without a manual dive into the database), the user is unable to see their new post.

Hopefully this makes some sense …

Thanks for thinking about it with us!

(Sam Saffron) #2

Curious, can you run the following

./launcher ssh app
% rails c
> SiteSetting.uncategorized_category_id
> Category.find(11

Is your uncategorized category somehow messed up?

What do you see in /var/docker/shared/logs/rails/production_errors.log
/var/docker/shared/logs/rails/production.log when the error happens?

Job failures make sense to me, it probably failed to save but queued a job inside the transaction.

(Christopher Baker) #3

Hi @sam, thanks for taking a look at it! Here’s what I have:

root@olab:~# rails c
Loading production environment (Rails 4.0.4)
irb(main):001:0> SiteSetting.uncategorized_category_id
=> 1
irb(main):002:0> Category.find(1)
=> #<Category id: 1, name: "xxxxxxxx__________blah", color: "AB9364", topic_id: nil, topic_count: 2, created_at: "2013-11-16 05:23:02", updated_at: "2014-04-05 18:43:14", user_id: -1, topics_year: 0, topics_month: 0, topics_week: 0, slug: "xxxxxxxx----------blah", description: "", text_color: "FFFFFF", read_restricted: true, auto_close_hours: nil, post_count: 28, latest_post_id: 1156, latest_topic_id: 407, position: 5, parent_category_id: 34, posts_year: 28, posts_month: 1, posts_week: 1, email_in: nil, email_in_allow_strangers: false, topics_day: 0, posts_day: 0>

I couldn’t actually find a /var/docker/shared/log/rails/production_errors.log (I didn’t have a logs directory so I assumed you meant log). I did have a production.log, but didn’t see anything related to that category or any errors at all for that matter.

The strange category name xxxxxxxx__________blah was me trying to change the name … in order to try to figure out what was going on (I did that a few days ago) - I didn’t make the connection that the errors were happening with the official “uncategorized” category – I just thought it was an empty category that wasn’t showing up anywhere … anyway, perhaps you can divine some meaning from that category info dump?

Any other places where I might look for the production error log (sorry, my rails+docker knowledge is lacking)?

(Sam Saffron) #4

Why does uncategorized have a parent category, you are playing with fire there. Can you rename it back to uncategorized and place it back in root?

(Jeff Atwood) #5

We need to make it so that uncategorized cannot be made parent or child of any other categories…

(Christopher Baker) #6

Well, I don’t know why it has a parent category – I’d guess it was an unintentional error on my part. I renamed it and removed the parent. Somehow the parent category was the new staff category, which would probably explain the permissions problems. I’ll run our tests again and see what happens.

(Christopher Baker) #7

Unfortunately after moving the uncategorized category out from under a parent category and renaming it, we’re still occasionally having this same problem, reproducible by the original steps. Basically for some strange reason – sometimes, but not always – non-staff users creating topics with links seems to reset their category setting to uncategorized and lock them out of their post, resulting an an uncategorized post that is saved, but only visible to those with staff+ permissions.

Any ideas? The link thing may be a red herring, but perhaps it has something to do with permissions?

(Jeff Atwood) #8

Is this working now on latest? Can you confirm @eviltrout that it is no longer possible to make uncategorized a subcategory or parent?

(Christopher Baker) #9

If it is helpful, we’ve kept up to date, but for some reason, users still end up creating new topics in the “uncategorized” topic.

We’re on now and our situation is still accurately described by the 12 April post above.

I’m not sure how to solve it, but I’m happy to send you logs, run queries or give you access to the server if you want to poke around.

Thanks for checking in!


(Kane York) #10

No, you can still do this:

You cannot set uncategorized as a parent, but you can still set its parent.

(Robin Ward) #11

I’ve got a fix to prevent people from setting a parent for it now.


(Jeff Atwood) #12