Duo Health check crashes because user is not set

The following discussion from !185263 (merged) should be addressed:

image

The fix is simple:

diff --git a/ee/lib/gitlab/llm/ai_gateway/code_suggestions_client.rb b/ee/lib/gitlab/llm/ai_gateway/code_suggestions_client.rb
index 503953a76c79..9c62df56ddf1 100644
--- a/ee/lib/gitlab/llm/ai_gateway/code_suggestions_client.rb
+++ b/ee/lib/gitlab/llm/ai_gateway/code_suggestions_client.rb
@@ -125,7 +125,7 @@ def task
             }
           }
 
-          CodeSuggestions::Tasks::CodeCompletion.new(unsafe_passthrough_params: inputs)
+          CodeSuggestions::Tasks::CodeCompletion.new(unsafe_passthrough_params: inputs, current_user: user)
         end
         strong_memoize_attr :task

On top of that I suggest:

  • Consider making this a mandatory parameter so that we fail fast if it's not set
  • Update the spec to invoke this code path so it doesn't fall through the cracks again
Edited by Matthias Käppler