Allow duo_workflow_file_attachments_enabled in AI feature settings
What does this MR do and why?
Updates the app/validators/json_schemas/ai_setting_feature_settings.json to include a new instance level setting duo_workflow_file_attachments_enabled, its SaaS top level group equivalent is being added in !268282 (merged).
This new setting will allow instance level admins to toggle file upload in agentic chat.
Rolling deploy issue
We are including schema and API changes that could cause a rolling deploy issue if the new duo_workflow_file_attachments_enabled is updated by the API during the rolling deploy window.
I believe this is a safe risk as it can only happen in 2 scenarios.
- A user makes a
PUT /application/settingscall manually and includesduo_workflow_file_attachments_enabledwhich is unlikely as it is a new setting.- They will then need to make a new call that lands on an old node that is not aware of
duo_workflow_file_attachments_enabled
- They will then need to make a new call that lands on an old node that is not aware of
- A user makes a call that runs
Ai::Setting.newon a new node, this automatically includesduo_workflow_file_attachments_enabled- They then call any update that lands on the old node.
- I think this is unlikely as they will need to have not used
Ai::Settingin the past, and it will need to be created in a rolling deploy window.
I also want to merge both schema and API this milestone, so next milestone we can merge the UI changes and not worry about API/UI rolling deploy issues.
References
Admin setting issue: https://gitlab.com/gitlab-org/gitlab/-/work_items/633198
File upload epic: &20481
Full PoC: !268274
Database
SELECT
"organizations".*
FROM
"organizations"
WHERE
"organizations"."id" = 1https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/83160/commands/190446
UPDATE
"ai_settings"
SET
"updated_at" = '2026-11-09 08:26:16.393901',
"feature_settings" = '{"duo_cli_enabled":true,"duo_agent_platform_enabled":true,"duo_token_usage_tracking_enabled":true,"ai_audit_events_streaming_enabled":false,"duo_workflow_file_attachments_enabled":true}'
WHERE
"ai_settings"."id" = 1https://console.postgres.ai/gitlab/projects/gitlab-production-main/sessions/83160/commands/190450
How to set up and validate locally
There is no UI or functional changes, so I have written a script to test the new API
Script
# frozen_string_literal: true
# Exercises the instance setting duo_workflow_file_attachments_enabled through the
# application settings REST API, as an admin would.
# Rails handles setup and teardown: the token and restoring the original value.
# Run: cd /home/kaveh/gdk/gitlab && bundle exec rails runner /home/kaveh/gdk/kaveh/test_instance_file_attachments.rb
require 'net/http'
SETTING = 'duo_workflow_file_attachments_enabled'
user = User.find_by_username!('root')
organization = Organizations::Organization.default_organization
saas = Gitlab::Saas.feature_available?(:gitlab_com_subscriptions)
# admin_mode lets the token call admin endpoints when admin mode is enforced
token = PersonalAccessTokens::CreateService.new(
current_user: user,
target_user: user,
organization_id: organization.id,
params: { name: 'kaveh-instance-file-attachments-test', scopes: [:api, :admin_mode], expires_at: 1.day.from_now }
).execute.payload[:personal_access_token]
raise 'token not created' unless token
TOKEN = token.token
API_URL = "#{Gitlab.config.gitlab.url}/api/v4"
def log(message)
return
puts("kaveh-log #{message}")
end
def request(method, path, body = nil)
uri = URI("#{API_URL}#{path}")
request = Net::HTTP.const_get(method.to_s.capitalize).new(uri)
request['PRIVATE-TOKEN'] = TOKEN
request['Content-Type'] = 'application/json'
request.body = body.to_json if body
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request(request) }
parsed = response.body.present? ? Gitlab::Json.parse(response.body) : nil
log("#{method.upcase} #{path} -> #{response.code}")
[response.code.to_i, parsed]
end
# rails runner wraps the script in the Rails executor, so SafeRequestStore and the
# Active Record query cache last the whole run; bypass both to see what Puma wrote.
def stored_value(organization)
Ai::Setting.uncached { Ai::Setting.find_by(organization_id: organization.id)&.public_send(SETTING) }
end
original = stored_value(organization)
# A) What GET /application/settings returns before any change
_, before = request(:get, '/application/settings')
# B) Turn it on, then off, checking the response, a fresh GET and the database each time
steps = [true, false].map do |value|
put_status, put_body = request(:put, '/application/settings', { SETTING => value })
_, get_body = request(:get, '/application/settings')
{
sent: value,
put_status: put_status,
put_error: (put_body['message'] || put_body['error'] unless put_status == 200),
put_returned: put_body&.key?(SETTING) ? put_body[SETTING] : 'not included',
get_returned: get_body&.key?(SETTING) ? get_body[SETTING] : 'not included',
stored: stored_value(organization)
}
end
# C) Restore the value the instance had before the run
Ai::Setting.for_organization(organization).update!(SETTING => original)
token.revoke!
puts
puts '=== Summary ==='
puts "SaaS (gitlab_com_subscriptions): #{saas}"
puts "AI features licensed: #{License.ai_features_available?}"
puts "original value (restored): #{original}"
puts "exposed before includes it: #{before&.key?(SETTING) || false}"
steps.each do |step|
worked = step[:put_status] == 200 && step[:stored] == step[:sent]
puts
puts "set to #{step[:sent]}:"
puts " update worked: #{worked}"
puts " update HTTP status: #{step[:put_status]}"
puts " update error: #{step[:put_error]}" if step[:put_error]
puts " value in DB (Rails check): #{step[:stored]}"
puts " PUT response returned: #{step[:put_returned]}"
puts " GET afterwards returned: #{step[:get_returned]}"
endOutput:
kaveh@kvejad--20251026-73SB4:~/gdk/gitlab$ GITLAB_SIMULATE_SAAS=0 bundle exec rails runner /home/kaveh/gdk/kaveh/test_instance_file_attachments.rb
=== Summary ===
SaaS (gitlab_com_subscriptions): false
AI features licensed: true
original value (restored): false
exposed before includes it: true
set to true:
update worked: true
update HTTP status: 200
value in DB (Rails check): true
PUT response returned: true
GET afterwards returned: true
set to false:
update worked: true
update HTTP status: 200
value in DB (Rails check): false
PUT response returned: false
GET afterwards returned: falseMR 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.
Related to #633198