Fix chat problem when instance setting is off
What does this MR do and why?
This fix addresses a bug in the Duo feature availability check logic. Previously, we were incorrectly checking the application setting 'duo_features_enabled' to determine if Duo should be available in a project. This approach didn't account for the instance-level configuration where Duo could be disabled by default but explicitly enabled for specific projects.
The corrected logic now properly checks if Duo features are banned at the instance level instead. This means that:
- When Duo is disabled by default on the instance, projects can still opt in to use it unless explicitly banned.
- The project-level Duo setting is respected regardless of the instance default configuration.
- Only when Duo is explicitly banned at the instance level will it be unavailable to all projects.
This change ensures that projects can successfully enable and use Duo features even when Duo is disabled by default at the instance level, aligning with our expected behavior for granular feature controls.
Technical implementation detail: We've updated the feature availability check to use lock_duo_features_enabled? instead of duo_features_enabled? to properly respect the instance-level configuration while maintaining project-level autonomy.
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
| Before | After |
|---|---|
How to set up and validate locally
on master:
- switch your instance to self-managed mode
- make sure you have chat working properly
- go to Admin> Gitlab Duo > configuration
- Switch duo off by default, save
- go to project with duo enabled - the chat breadcrumb should not be visible
on this branch:
- switch your instance to self-managed mode
- make sure you have chat working properly
- go to Admin> Gitlab Duo > configuration
- Switch duo off by default, save
- go to project with duo enabled - the chat breadcrumb should be visible
Additional check on this branch:
- switch your instance to self-managed mode
- make sure you have chat working properly
- go to Admin> Gitlab Duo > configuration
- Switch duo to always off, save
- restart gdk
- go to project with duo enabled - the chat breadcrumb should not be visible
Note: without restarting gdk, the chat breadcrumb is disabled, but it is visible. I assume it's some caching issue. Something we may want to investigate.
Related to #510624 (closed)