Assigning parent category to a category that already has subcategory produces error

I managed to figure out how to solve this, but thought it was worth reporting.

I attempted to assign a parent category, cat-B, to cat-A which already had 3 subcategories in it. The Discourse system gave me an error message and said something like ‘we can’t move subcategories’. So I’m guessing there’s a limit to how many categories can be nested within each other.

I concluded that’s fine, I’ll just reassign the parent category for the 3 subcategories first. But when I tried to do that, I got an exception error like this.

The console gives a 404 error for the URL ending in c/cat-B/cat-A/subcategory/edit/find_by_slug.json

A similar error shows up for the other 2 subcategories of cat-A.

What it should show instead is c/cat-A/subcategory/edit without the cat-B. So I manually typed the URL with this format and got to the normal category settings page as expected. I was able to fix all 3 subcategories and cat-A in this way.

This is probably just a small bug that would be worth fixing in the future :muscle:

2 Likes

Do you know what version of Discourse your site is using? If your site is self-hosted, you can find the version near the top of the site’s admin dashboard. The reason I am asking is because I think Discourse should have prevented you from adding the parent category. When I try to do it, I get the following error:

It is possible that you are running into a bug that has been fixed in a more recent version of Discourse. It is also possible that I am not reproducing the issue correctly.

3 Likes

Thanks for the help @simon

The site is self hosted and seems to be the latest version.

Here are the version details. Does that help?

1 Like

Are there any error details when you visit the page at /logs?

1 Like

I didn’t see any relevant error details on /logs. I’m not a developer, so I may have missed something.

However, I was able to reproduce the error. It seems consistent enough. I also checked /logs and nothing new was there.

Here’s the message I got when I attempted to assign a parent category to one that already had subcategories.

image

Here are more details of what’s happening in the aftermath:

1. With regards to Cat-A
the category with subcategories that I attempted to assign a new parent category to

  • Cat-A shows up on the category home page as normal. Navigating through Cat-A and subcategories behaves as normal.
  • Cat-A no longer appears on the primary navigation menu under all categories
    image
  • When Editing Cat-A, a 404 error appears saying that page is not visible.

2. With regards to Cat-B
this is what I attempted to assigned Cat-A to

  • Cat-A is showing up in the dropdown of Cat-B
    image
  • When Editing Cat-B, everything is normal

3. With regards to subcategories

When Editing any subcategory, this same error appears
image

Aaaannnd after writing all that, the error magically healed itself without me having to use the manually-type-in-the-URL workaround. Seems like it’s all good now folks.

2 Likes