fix(ai): valid Tailwind token + base_url URL validation

- Data-handling block in _llm_provider_selector swaps the invalid
  bg-surface-secondary token for bg-container-inset, matching the
  inset-card pattern used elsewhere in sure-design-system/components.css.
  bg-surface-secondary is not defined anywhere in the design system —
  Tailwind treated it as a no-op, so the block rendered with no
  background contrast.
- Settings::HostingsController validates anthropic_base_url as a
  URI::HTTP (catches https too) and raises Setting::ValidationError
  with a localized message when the input is not parseable.
  Previously any string was persisted, surfacing as an opaque
  connection error at request time instead of an immediate UX failure.
- Blank base_url now clears the setting (was already the case but
  exercised explicitly in tests now).
This commit is contained in:
Guillem Arias
2026-05-25 20:39:27 +02:00
parent c81055ea58
commit e7d4a00f73
4 changed files with 34 additions and 2 deletions

View File

@@ -101,6 +101,28 @@ class Settings::HostingsControllerTest < ActionDispatch::IntegrationTest
end
end
test "rejects non-URL anthropic base_url" do
with_self_hosting do
Setting.anthropic_base_url = nil
patch settings_hosting_url, params: { setting: { anthropic_base_url: "not-a-url" } }
assert_response :unprocessable_entity
assert_match(/Anthropic Base URL must be an http/, flash[:alert])
assert_nil Setting.anthropic_base_url
end
end
test "clears anthropic base_url when blank value submitted" do
with_self_hosting do
Setting.anthropic_base_url = "https://bedrock.example.com"
patch settings_hosting_url, params: { setting: { anthropic_base_url: "" } }
assert_nil Setting.anthropic_base_url
end
end
test "can update llm_provider to anthropic" do
with_self_hosting do
patch settings_hosting_url, params: { setting: { llm_provider: "anthropic" } }