diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index 002f2aa0103..6bc4fa406b7 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -503,7 +503,7 @@ class TopicsController < ApplicationController user = User.find_by(username: params[:username]) guardian.ensure_can_remove_allowed_users!(topic, user) - if topic.remove_allowed_user(current_user, user) + if topic&.remove_allowed_user(current_user, user) render json: success_json else render json: failed_json, status: 422