Fix FetchModelDefinitionsService to handle SM
What does this MR do and why?
Fix GraphQL crash in GitLab Duo Self-Hosted model configuration after v18.4 upgrade
Issue: After upgrading to GitLab v18.4, customers lose complete access to Duo Self-Hosted model configuration due to GraphQL errors. The FetchModelDefinitionsService
returns nil
instead of a ServiceResponse
object, causing NoMethodError: undefined method 'payload' for nil:NilClass
in the GraphQL resolver.
Root Cause: The service checks the wrong feature flag (:ai_model_switching
for group-level selection) when self-managed instances need instance-level model definitions regardless of group-level settings.
Fix:
- Remove
:ai_model_switching
check fromFetchModelDefinitionsService
- only checkduo_features_enabled
- Always return
ServiceResponse
objects (nevernil
) with graceful error handling - Update GraphQL resolver to safely handle
ServiceResponse
objects
Impact:
- Fixes complete Duo feature outage for self-managed customers
- Allows instance-level model selection without requiring group-level features
- Provides graceful degradation for network/API errors
Related Issues:
- Closes #571212 (closed)
- Customer tickets: https://gitlab.com/gitlab-com/request-for-help/-/issues/3444
How to set up and validate locally
- Try to edit or create a self-hosted model, with
ai_model_switching
FF disabled.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.