From ea96a51a2a53dd31980a3cce422e31036c694a03 Mon Sep 17 00:00:00 2001 From: Max Fan <mfan@gitlab.com> Date: Wed, 24 Jul 2024 11:53:34 -0700 Subject: [PATCH] Updating /troubleshoot rca to handle empty logs As any job can be passed, if there is no jog log we return an error message EE: true --- ee/lib/gitlab/llm/chain/tools/slash_command_tool.rb | 1 + .../llm/chain/tools/troubleshoot_job/executor.rb | 2 ++ .../chain/tools/troubleshoot_job/executor_spec.rb | 12 ++++++++++++ locale/gitlab.pot | 3 +++ 4 files changed, 18 insertions(+) diff --git a/ee/lib/gitlab/llm/chain/tools/slash_command_tool.rb b/ee/lib/gitlab/llm/chain/tools/slash_command_tool.rb index b90f44085cd36..64dcadc15ee6f 100644 --- a/ee/lib/gitlab/llm/chain/tools/slash_command_tool.rb +++ b/ee/lib/gitlab/llm/chain/tools/slash_command_tool.rb @@ -17,6 +17,7 @@ def perform Gitlab::ErrorTracking.track_exception(e) Answer.error_answer( + error: e, context: context, error_code: "M4000" ) diff --git a/ee/lib/gitlab/llm/chain/tools/troubleshoot_job/executor.rb b/ee/lib/gitlab/llm/chain/tools/troubleshoot_job/executor.rb index 293b862c09a6f..37375c239422b 100644 --- a/ee/lib/gitlab/llm/chain/tools/troubleshoot_job/executor.rb +++ b/ee/lib/gitlab/llm/chain/tools/troubleshoot_job/executor.rb @@ -77,6 +77,8 @@ def perform elsif !job.failed? _('This command is used for troubleshooting jobs and can only be invoked from ' \ 'a failed job log page.') + elsif !job.trace.exist? + _('There is no job log to troubleshoot.') end return error_with_message(error_message) if error_message diff --git a/ee/spec/lib/gitlab/llm/chain/tools/troubleshoot_job/executor_spec.rb b/ee/spec/lib/gitlab/llm/chain/tools/troubleshoot_job/executor_spec.rb index 0ef0cac814d5d..589f0e7543c36 100644 --- a/ee/spec/lib/gitlab/llm/chain/tools/troubleshoot_job/executor_spec.rb +++ b/ee/spec/lib/gitlab/llm/chain/tools/troubleshoot_job/executor_spec.rb @@ -129,6 +129,18 @@ tool.execute end + + context 'when log does not exist' do + before do + build.trace.erase! + end + + it 'returns an error message' do + expect(tool.execute.content).to include( + "There is no job log to troubleshoot" + ) + end + end end context 'when the feature is disabled' do diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 6aac19a426c1d..1f91c18763077 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -53839,6 +53839,9 @@ msgstr "" msgid "There is no data available. Please change your selection." msgstr "" +msgid "There is no job log to troubleshoot." +msgstr "" + msgid "There is no table data available." msgstr "" -- GitLab