From c16c622b53861d4f675f054c84632bdebf657591 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 31 Jul 2024 17:53:18 +1000 Subject: [PATCH] FIX: properly pass errors to client (#731) render_json_error expects a AR model not a serializer, using a serializer eats up the error message --- app/controllers/discourse_ai/admin/ai_llms_controller.rb | 4 ++-- app/controllers/discourse_ai/admin/ai_personas_controller.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/discourse_ai/admin/ai_llms_controller.rb b/app/controllers/discourse_ai/admin/ai_llms_controller.rb index 2292e98c..4707cb6b 100644 --- a/app/controllers/discourse_ai/admin/ai_llms_controller.rb +++ b/app/controllers/discourse_ai/admin/ai_llms_controller.rb @@ -38,7 +38,7 @@ module DiscourseAi llm_model.toggle_companion_user render json: { ai_persona: LlmModelSerializer.new(llm_model) }, status: :created else - render_json_error LlmModelSerializer.new(llm_model) + render_json_error llm_model end end @@ -49,7 +49,7 @@ module DiscourseAi llm_model.toggle_companion_user render json: LlmModelSerializer.new(llm_model) else - render_json_error LlmModelSerializer.new(llm_model) + render_json_error llm_model end end diff --git a/app/controllers/discourse_ai/admin/ai_personas_controller.rb b/app/controllers/discourse_ai/admin/ai_personas_controller.rb index 7dee516d..d3bcc7ef 100644 --- a/app/controllers/discourse_ai/admin/ai_personas_controller.rb +++ b/app/controllers/discourse_ai/admin/ai_personas_controller.rb @@ -63,7 +63,7 @@ module DiscourseAi render json: LocalizedAiPersonaSerializer.new(@ai_persona, root: false) else - render_json_error LocalizedAiPersonaSerializer.new(@ai_persona, root: false) + render_json_error @ai_persona end end @@ -71,7 +71,7 @@ module DiscourseAi if @ai_persona.destroy head :no_content else - render_json_error LocalizedAiPersonaSerializer.new(@ai_persona, root: false) + render_json_error @ai_persona end end