Updating deleted post through API returns Internal Server Error

Attempting to update a deleted post through the API returns a 500 error. The error is undefined method 'id' for nil:NilClass. It’s coming from web_hook.rb.

The problem is that when publishing with the All Users API key the post update method is calling
post = post.with_deleted if guardian.is_staff?. The deleted post is then being used to trigger a DiscourseEvent.

My reason for wanting to get a better response when a deleted post is updated is so that the WP Discourse plugin can use the response to remove the Discourse metadata it has saved for a post. It’s not safe for the plugin to assume that a 500 response means that the post has been deleted.

7 Likes

Sure, you can take this and fix the bug… it certainly seems like one.

3 Likes

Fixed per:

https://github.com/discourse/discourse/pull/5520

3 Likes