Add category: 500 error

I try to add a category to an old post that has been removed and restored but i get this error:

An the console error:

NoMethodError (undefined method `id' for nil:NilClass) /var/www/discourse/app/models/topic.rb:632:in `block in changed_to_category'

Version of Discourse: Version v1.9.0.beta4 +391

Can you give detailed steps of how to reproduce this problem? I tried but didn’t get an error. Also, try upgrading since beta4 is quite old now.