Can't Edit Category or Add Subcategories To It

AI-generated summary

In a Support discussion titled “Can’t Edit Category or Add Subcategories To It,” Eingang reports encountering a “422: Unprocessable Entity” error when trying to edit a restricted parent category or add a subcategory under it. The issue arose after upgrading to Discourse v2.3.0.beta7 and affects setups where the parent category’s see permission is assigned to a custom group (e.g., MyOwnEveryone) instead of the built-in everyone group. The error disappears if everyone see is temporarily added to the parent category. Eingang clarifies that their subcategories have more restrictive permissions (e.g., create, reply, see for SomeGroup A), and the parent’s group (MyOwnEveryone) includes all subcategory groups — but Discourse doesn’t recognize this hierarchy. Stephen explains this behavior is intentional: Discourse enforces that subcategories cannot have permissions less restrictive than their parent, a safeguard introduced in recent betas to prevent permission leaks. He notes that Discourse doesn’t enumerate group memberships recursively, and suggests that creating the subcategory with permissions matching the parent first would succeed. The issue is not a bug but a consequence of using categories in a way not originally intended by the system design.

Summary

On editing a restricted parent category or trying to add a new subcategory to a parent category, server returns “422: Unprocessable Entity”

Environment

  • Currently v2.3.0.beta7 +7 but problem first noticed several weeks back after being told there was a major update (which may have needed to be installed via command line and not via web interface?)

  • CentOS Linux release 7.6.1810

Discussion

This may be related to Unable to set up permissions on parent/subcategory and it’s definitely popped up fairly recently. As described in that post, I have a top-level category that is set for a group to see only. It’s really a container for the subcategories. Unlike their setup, my see group isn’t everyone. It’s a specific group that encompasses all the members of the subcategory groups (who can see, reply, and create).

Unless I set the parent container now to include everyone see, if I try to add a subcategory to the parent or edit something about the parent, I inevitably will get a 422: Unprocessable Entity. If I add everyone see into the parent category, it suddenly works.

I don’t have everyone see as a permission because sign-in is managed by OAUTH via another product. Anyone who can sign-in there should not be able to see anything on my Discourse unless they’re in a specific group, so I don’t use everyone almost anywhere.

I suspect I can add everyone see to the parent category to make changes/add new subcategories, and then remove it when I’m done. I’ll try testing that. In any case, the error message (which I also see pop up at other times) is particularly uninformative and the logs didn’t seem to show anything obvious I could see.

So if you add the same permissions as the parent prior to creation it fails?

Does this make it clearer?

  • Parent category has see permissions for a group called MyOwnEveryone;
  • Subcategory is being added with create, reply, see permissions for a group called SomeGroup A.
  • MyOwnEveryone includes all members of SomeGroup A, SomeGroup B, SomeGroup C, etc, but is not the predefined everyone group for reasons mentioned in my original post.

So Discourse fails to recognize that SomeGroup B is a subset of MyOwnEveryone. This isn’t completely surprising, I suppose, but it’s inconvenient, and it was working before. :-o

That’s correct, Discourse doesn’t enumerate group memberships.

This is by design. Subcategories can’t have permissions that are less restrictive than their parents. A check was added for this during the recent betas:

:white_check_mark: Do not allow saving a category if child permissions are LESS restrictive than parent: Subcategories do not inherit permissions from parent category @maja

Source: Discourse 2.3 notes

This is why I asked:

It’s not a category creation error, you’re just using categories in a way that isn’t intended. Had you tried what I asked it would have worked.