Error 422 when reordering categories

AI-generated summary

A user, Christina, reports a 422 error when trying to reorder categories in Discourse 3.1.0.beta4, noting that the category order in the UI doesn’t match the reorder page. The error occurs after moving a newly created category (via API) to the first position, and the console shows a JSON parsing error due to unexpected HTML content. Despite being an admin, she cannot save changes. JammyDodger suggests the issue might stem from how the category was created outside the UI, while Christina notes she’s created many categories similarly without issues, though one failed due to a name too long. Canapin recommends checking the category data via the rails console or data explorer for anomalies. The issue was moved to Product Support, and no resolution has been confirmed yet Christina, JammyDodger, Canapin, JammyDodger.

Good morning,

Discourse version 3.1.0.beta4
I’m trying to reorder the categories from the UI and when I press save order I get a 422 error. Interesting fact: my categories on the main Discourse page doesn’t have the same order on the reorder categories page.
Example : I have the supervisor category at position 4 on my main page, on the other hand when I go on the reorder categories page, the supervisor category is not at position 4, but at position 23 and if I press on save , it will go to position 23 as shown in the reorder categories page. I have the 422 error that appears, but there are still changes that have taken place.
Last week I had no problems with the reorganization, I only had this problem when I moved the new category my script created today to the first position.
In the preview page of Chrome I have a little more details about the error:
The change you wanted was rejected. Maybe you tried to change something you didn’t have access to.

I’m admin, so I shouldn’t get this error.
In the source code I have this exception that throws :
SyntaxError: Unexpected token ‘<’ "<!DOCTYPE "… is not a valid JSON

I’ve:
Done a server reboot
Enabled Allow Uncategorized Topic option

Do you have an idea what I could do ?

I’m afraid I can’t replicate this on my test site. When I change the order of the categories they reorder without any error.

Could it be something to do with how you’ve created this category outside of the UI?

Maybe, but I’ve done lots of categories this way and never had an issue. I did it through the API. I know that one of my categories had a name too long and my script was not able to create it, do you think it could be the issue ?

You could try output your category data via the rails console or data explorer, and see if there’s anything weird in it. :thinking:

I’ve slipped this over to Support as we couldn’t get a clear repro.

Did you manage to resolve this in the end?