Topics failing validation after migration throw '422' error instead of "nice" message

AI-generated summary

When migrating topics from another platform, they may be considered “invalid” on Discourse due to title length or word count limits. If a user attempts to edit these topics, especially by changing the category, they may receive a 422 error instead of a more informative message. jomaxro suggests that the system should provide a more specific cause of the error. codinghorror inquired whether the error only occurs when changing categories, and jomaxro confirmed that the issue is inconsistent but seems to be related to category-only edits. codinghorror notes that this issue mainly affects topic owners, staff, or TL3 users. tophee confirmed the behavior and proposes displaying a more meaningful error message or allowing non-compliant topic titles when moving categories.

When data is migrated from another software platform it is possible that topics migrated would be considered “invalid” if created on Discourse. Common causes of “invalid” topics are min topic title length, max topic title length, and title max word length. If a user attempts to edit these topics (including changing category) they receive a 422 error, instead of the standard Title seems unclear, is it a complete sentence?.

Further, it’d be great if we could share the specific cause of the error (word is too long, for example) instead of the vague “title seems unclear”.

6 Likes

Do they also get 422 if they edit the title? Or is this specific to changing category?

1 Like

I’m not able to consistently reproduce this on try, so I’m not sure. I created a topic with a 28 character word in the title (limit is 30), submitted, waited 5 minutes, lowered the site setting to a 20 character limit, then changed the category without error (which should have failed?). Attempting to add to the title gave the expected Title seems unclear, is it a complete sentence? error. If I modified the title and changed the category I received a 422 error, but this is not consistent with what I first saw.

So as suspected this has to do with category only edits triggering validation on the title. So only the topic owner, staff, or TL3 could really run into this.

1 Like

I can confirm this behaviour. We imported all topics into “uncategorized” and are now gradually recategorizing them. I just bumped into that 422 error. After reading this topic, I changed the title to make it comply with the minimum length and it worked. But it would obviously be nicer to have a meaningful error message, even if it just pointed into a general direction like “Topic failed validation. Does the title meet requirements?”. Even better would be to not produce an error at all and continue to allow non-compliant topic titles even when they are moved.

2 Likes