422 Unprocessable Content response when using ActivityPub with WP Discourse

I am using the latest WordPress version together with latest wordpress plugin. Upon posting automagically from WP into Discourse, I get this error:

A post has failed to publish on Discourse from your site [netzwissen.de]. The post '@netzwissen.de Migration erledigt' was published on WordPress by autor01, on 2024-01-01 13:34:14. [<https://www.netzwissen.de/2024/01/01/netzwissen-de-migration-erledigt/>](https://www.netzwissen.de/2024/01/01/netzwissen-de-migration-erledigt/)

Reason for failure: A 422 response code was returned from Discourse. Embed url wird bereits verwendet If you're having trouble with the WP Discourse plugin, you can find help at: [<https://meta.discourse.org/c/support/wordpress>](https://meta.discourse.org/c/support/wordpress)

Despite this error, the post appears in Discourse, but with some empty <div> ...</div> blocks which come from the Divi theme framework in WordPress (Divi — The Ultimate WordPress Theme & Visual Page Builder). Shouldn’t such html/css code be removed automatically processing into the bbcode/md scheme at Discourse?

Hey Thomas, my initial thought is that the error is occurring because the post is being sent to Discourse twice and the HTML issue is separate. Let’s start with the double-publishing issue. Could you confirm a few things for me:

  1. Where are you seeing this error? In the Logs Viewer in the WP Discourse plugin?
  2. Do you see this on all posts being published to Discourse or only some?
  3. Are you scheduling the posts?
  4. Which Wordpress composer are you using to compose the posts (classic or gutenberg)?
  5. Are you using any other theme or plugin or customisation that affects the way you post in Wordpress?
2 Likes

Hi Angus, first a “happy new year” to Scotland (I assume) :sunny:

its an error mail coming from the WP CMS, so its created from the WP plugin code and sent through the CMS framework.

all posts so far

No. But I edited the post on WP and saved it as draft before publishing it finally. So, theoretically, the “publish” including the “publish to Discourse API” should only appear once …

I use the Divi theme and in-build composer from

Havent’t tested with Gutenberg or the classic one yet.

1 Like

Could you head over to the Logs view in WP Discourse, click “Download” and PM me the downloaded file? That’ll help me get a better understanding of your environment, settings and the error. Thanks!

Happy new year as well! (I’m only Australian unfortunately, much less interesting :wink: )

3 Likes

Hey! I have the exact same problem atm and can’t solve it by my own. Everytime I publish an article, it doesn’t connect it with the discourse topic. Same error code as above. Would love to hear if you found a solution.

Do you also have the ActivityPub plugin enabled? If so, it is not yet compatible with embedded topics created by the WP Discourse plugin (which was the issue in this topic).

1 Like

Unfortunately that’s not the problem then for me. I don’t have that plugin.

Hey @Miasanrot could you create a new topic with some more details of the issue you’re seeing? In particular:

  1. Logs from WP Discourse, including the meta file.
  2. Logs from Discourse, in particular the error log.
  3. A list of plugins you’re using in Discourse.

Thanks!

As @Miasanrot has no ActivityPub plugin, I would guess that the problem is the content which is delivered from the WP plugin into the Discourse API. Maybe https://github.com/discourse/wp-discourse/blob/main/lib/discourse-publish.php needs a bit more trimming before creating a Discourse post entry from it …

Hey @Thomas_Rother, there are various ways this error can occur. It’s best to approach them individually.