Duo Health check crashes because user is not set
The following discussion from !185263 (merged) should be addressed:
-
@mkaeppler started a discussion: (+4 comments) @eduardobonet I'm not sure why, but this broke the Duo Health Check because it does not pass a
usertoTasks::CodeCompletion: https://gitlab.com/gitlab-org/gitlab/-/blob/a8103a23a6722a7a6138f5da21cac9129a46fef2/ee/lib/gitlab/llm/ai_gateway/code_suggestions_client.rb#L128Any idea why the user is an optional parameter? We should probably make this a required argument if we call methods on it later?
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
