From 73c2690526d626bbf59ba67b5ed202743ddf63bd Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Mon, 4 Aug 2025 15:42:43 +0530 Subject: [PATCH] fix: handle conversation is nil --- .../app/services/captain/assistant/agent_runner_service.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/enterprise/app/services/captain/assistant/agent_runner_service.rb b/enterprise/app/services/captain/assistant/agent_runner_service.rb index 5dd225be5..c6a0860d8 100644 --- a/enterprise/app/services/captain/assistant/agent_runner_service.rb +++ b/enterprise/app/services/captain/assistant/agent_runner_service.rb @@ -27,7 +27,9 @@ class Captain::Assistant::AgentRunnerService process_agent_result(result) rescue StandardError => e - ChatwootExceptionTracker.new(e, account: @conversation.account).capture_exception + # when running the agent runner service in a rake task, the conversation might not have an account associated + # for regular production usage, it will run just fine + ChatwootExceptionTracker.new(e, account: @conversation&.account).capture_exception Rails.logger.error "[Captain V2] AgentRunnerService error: #{e.message}" Rails.logger.error e.backtrace.join("\n")