Skip to content
Snippets Groups Projects
Unverified Commit c47c724d authored by Julie Huang's avatar Julie Huang :two:
Browse files

Ensure empty strings are coerced to nil when saving ai_gateway_url

parent b811a384
No related branches found
No related tags found
3 merge requests!181325Fix ambiguous `created_at` in project.rb,!181225[FIX] Ensure blank strings are coerced to nil before saving ai_gateway_url,!180727Resolve "Extend job archival mechanism to the whole pipeline"
......@@ -18,7 +18,7 @@ class Update < BaseMutation
def resolve(**args)
raise_resource_not_available_error! unless Ability.allowed?(current_user, :manage_self_hosted_models_settings)
result = ::Ai::DuoSettings::UpdateService.new(ai_gateway_url: args[:ai_gateway_url]).execute
result = ::Ai::DuoSettings::UpdateService.new(ai_gateway_url: args[:ai_gateway_url].presence).execute
if result.error?
{
......
......@@ -63,6 +63,21 @@
expect { duo_settings.reload }.to change { duo_settings.ai_gateway_url }.to("http://new-ai-gateway-url")
end
context 'when ai_gateway_url arg is a blank string' do
let(:mutation_params) { { ai_gateway_url: "" } }
it 'coerces it to nil' do # an empty string will cause the Duo healthcheck to error
request
result = json_response['data']['duoSettingsUpdate']
expect(result).to include("aiGatewayUrl" => nil)
expect(result['errors']).to eq([])
expect { duo_settings.reload }.to change { duo_settings.ai_gateway_url }.to(nil)
end
end
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment