Error message "embed url already being used" even after unlinking post from discourse

I have an existing wp post which used to be published the forum as well.
At some point every time I update the post by clicking the save link, I get an email with following error message:

Discourse Publishing Failure

A post has failed to publish on Discourse from your site ...

...

Reason for failure:
A bad response was returned from Discourse.
Embed url wird bereits verwendet (translates to  "is being used already")

I unlinked the post from discourse. Also I deleted the post in the forum. Yet the error keeps popping up with every save of the post. Also when trying to publish post as new topic, the same error comes up.

1 Like

There was a bug in the plugin that was causing it to attempt to republish posts to Discourse after they had been unlinked on WordPress when the Auto Publish setting is enabled and posts are published with the Block Editor. Publishing the post to Discourse would fail, because the embed URL was already being used on Discourse. I fixed this issue yesterday, but the fix only applies to newly unlinked posts. I’ll come up with something that can fix the issue for posts that were unlinked in the past.

When posts are unlinked, the plugin isn’t removing the topic’s embed_url on Discourse. This means that if a post is unlinked and then republished to Discourse, publishing will fail with the Embed url is already being used error. I’ll fix this.

If you have deleted the associated topic on Discourse, it should be possible to republish the post to Discourse without errors. I’ll check to make sure that the embed_url is removed on Discourse when a topic is deleted.

I’ll be updating the plugin later this week, or some time over the weekend. That update should take care of the issues you are having with unlinked posts.

2 Likes

thx for the detailed answer! is there any manual workaround for now?

To prevent getting the error message when a post that you have unlinked from Discourse is updated on WordPress, add a post custom field with the name wpdc_auto_publish_overridden and its value set to 1.

If custom fields are not yet enabled on the Block Editor:

  1. Click on the block editor settings (three dots) in the top-right corner of the page and select “Options”.
  2. Select “Custom Fields” in the “Advanced Panels” section.
1 Like

I’ve just pushed WP Discourse version 2.0.4 to the WordPress repo. It will handle the issue with posts that were unlinked from Discourse when a site was on a version of the plugin less than 2.0.3. For these posts, the first time you update the unlinked post you will see the Embed url has already been taken error message. After the initial update, you will no longer see the error message (or be sent the publishing error email.) It’s not a perfect solution, but it’s the best way to resolve that issue.

If you attempt to publish a post to Discourse when there is already a Discourse topic that is using its embed URL, you will get an error. If you delete the topic on Discourse that is using the embed URL, you should be able to republish the topic. It takes Discourse some time to delete the Topic Embed that is associated with the WordPress post. I still need to confirm what sets the time period for this. Let me know if you are still having trouble with this.

Ideally, when a WordPress post is unlinked from a Discourse topic, the embed_url that is associated with the post would be deleted on Discourse. Unfortunately, it is not currently possible to remove a topic’s embed_url through the Discourse API. It might be possible to get this to work in the future. A smaller change that would be helpful for the WP Discourse plugin would be to have Discourse return the topic_id when it returns the Embed url has already been taken error message. That way the WP Discourse plugin could let users know which topic on Discourse is causing the issue.

1 Like