Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 584f5f2

Browse files
authored
DEV: Use full URL for problem check message (#1165)
Better to construct the URL in Ruby and pass it to I18n, so we don't have to mess with the translations if the URL changes.
1 parent fff0bc0 commit 584f5f2

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

app/services/problem_check/ai_llm_status.rb

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ def call
88
llm_errors
99
end
1010

11-
def base_path
12-
Discourse.base_path
13-
end
14-
1511
private
1612

1713
def llm_errors
@@ -26,20 +22,21 @@ def try_validate(model, &blk)
2622
blk.call
2723
nil
2824
rescue => e
29-
error_message = parse_error_message(e.message)
30-
message =
31-
"#{I18n.t("dashboard.problem.ai_llm_status", { base_path: base_path, model_name: model.display_name, model_id: model.id })}"
25+
details = {
26+
model_id: model.id,
27+
model_name: model.display_name,
28+
error: parse_error_message(e.message),
29+
url: "#{Discourse.base_path}/admin/plugins/discourse-ai/ai-llms/#{model.id}/edit",
30+
}
31+
32+
message = I18n.t("dashboard.problem.ai_llm_status", details)
3233

3334
Problem.new(
3435
message,
3536
priority: "high",
3637
identifier: "ai_llm_status",
3738
target: model.id,
38-
details: {
39-
model_id: model.id,
40-
model_name: model.display_name,
41-
error: error_message,
42-
},
39+
details:,
4340
)
4441
end
4542
end

config/locales/server.en.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,4 +484,4 @@ en:
484484
prompt_message_length: The message %{idx} is over the 1000 character limit.
485485
dashboard:
486486
problem:
487-
ai_llm_status: "The LLM model: %{model_name} is encountering issues. Please check the <a href='%{base_path}/admin/plugins/discourse-ai/ai-llms/%{model_id}/edit'>model's configuration page</a>."
487+
ai_llm_status: "The LLM model: %{model_name} is encountering issues. Please check the <a href='%{url}'>model's configuration page</a>."

spec/services/problem_check/ai_llm_status_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@
4242
it "returns a problem with an LLM model" do
4343
stub_request(:post, post_url).to_return(status: 403, body: error_response, headers: {})
4444
message =
45-
"#{I18n.t("dashboard.problem.ai_llm_status", { base_path: Discourse.base_path, model_name: llm_model.display_name, model_id: llm_model.id })}"
45+
I18n.t(
46+
"dashboard.problem.ai_llm_status",
47+
{
48+
model_name: llm_model.display_name,
49+
url: "/admin/plugins/discourse-ai/ai-llms/#{llm_model.id}/edit",
50+
},
51+
)
4652

4753
expect(described_class.new.call).to contain_exactly(
4854
have_attributes(
@@ -53,6 +59,7 @@
5359
details: {
5460
model_id: llm_model.id,
5561
model_name: llm_model.display_name,
62+
url: "/admin/plugins/discourse-ai/ai-llms/#{llm_model.id}/edit",
5663
error: JSON.parse(error_response)["message"],
5764
},
5865
),

0 commit comments

Comments
 (0)