Replace remaining AvailableServices.find_by_name calls
Goal
Replace all remaining AvailableServices.find_by_name calls with unit_primitive_name.to_sym. Most of these are simple replacements since they only call AiGateway client header methods which ultimately call user.allowed_to_use from UserAuthorizable.
This will remove the last need for callers to locate service objects.
Rollout
Step 0: Prepare
Temporarily patch AiGateway.headers to accept a UP symbol for service arguments (see snippet). This allows us to start cutting over to passing UP names at the call site instead of a service object.
Step 1: Cutting over
Update all call sites to pass UP names instead of service objects. This work can happen in parallel.
Files to change:
-
ee/app/policies/ee/global_policy.rb- Global Policy duo_chat method -
ee/lib/gitlab/llm/ai_gateway/client.rb- AI Gateway Client base class-
@mkaeppler- !203115 (merged)
-
-
ee/lib/gitlab/llm/ai_gateway/code_suggestions_client.rb- Code Suggestions Client-
@mkaeppler- !202918 (merged)
-
-
ee/lib/gitlab/llm/ai_gateway/docs_client.rb- Docs Client -
ee/lib/gitlab/llm/anthropic/client.rb- Anthropic Client -
ee/lib/gitlab/llm/vertex_ai/configuration.rb- Vertex AI Configuration -
ee/lib/gitlab/llm/q_ai/client.rb- Q AI Client-
@mkaeppler- !203394 (merged)
-
-
ee/lib/gitlab/duo/chat/step_executor.rb- Duo Chat Step Executor -
ee/app/services/ai/model_selection/fetch_model_definitions_service.rb- Model Selection Service-
@mkaeppler- !203400 (merged)
-
-
ee/lib/api/internal/ai/x_ray/scan.rb- X-Ray Scan API -
ee/lib/api/code_suggestions.rb- Code Suggestions API-
@mkaeppler- !202918 (merged)
-
Step 2: Cleaning up - @alipniagov - WIP - !203830 (merged)
- Remove the temporary workaround that accepts both
serviceobjects and UP names. We only accept UP names now. - Rename the
serviceparameter tounit_primitive_name
Edited by Matthias Käppler