Skip to content

Commit 37e245d

Browse files
frantic-openaicodex
andcommitted
fix(status-dashboard): normalize backoff queue error newlines
Summary: - Normalize escaped and raw newline sequences before rendering retry errors. - Add dashboard snapshot coverage for escaped `\\n` handling in backoff queue rows. Rationale: - Prevent malformed backoff rows when upstream error messages include escaped newlines. - Keep dashboard layout stable while preserving compact human-readable error text. Tests: - cd elixir && mix test test/symphony_elixir/status_dashboard_snapshot_test.exs Co-authored-by: Codex <codex@openai.com>
1 parent a0587ee commit 37e245d

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

elixir/lib/symphony_elixir/status_dashboard.ex

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,16 @@ defmodule SymphonyElixir.StatusDashboard do
675675
defp next_in_words(_), do: "n/a"
676676

677677
defp format_retry_error(error) when is_binary(error) do
678-
sanitized = error |> String.replace(~r/\s+/, " ") |> String.trim()
678+
sanitized =
679+
error
680+
|> String.replace("\\r\\n", " ")
681+
|> String.replace("\\r", " ")
682+
|> String.replace("\\n", " ")
683+
|> String.replace("\r\n", " ")
684+
|> String.replace("\r", " ")
685+
|> String.replace("\n", " ")
686+
|> String.replace(~r/\s+/, " ")
687+
|> String.trim()
679688

680689
if sanitized == "" do
681690
""

elixir/test/symphony_elixir/status_dashboard_snapshot_test.exs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,34 @@ defmodule SymphonyElixir.StatusDashboardSnapshotTest do
138138
Snapshot.assert_dashboard_snapshot!("backoff_queue", render_snapshot(snapshot_data, 15.4))
139139
end
140140

141+
test "backoff queue row escapes escaped newline sequences" do
142+
snapshot_data =
143+
{:ok,
144+
%{
145+
running: [],
146+
retrying: [
147+
retry_entry(%{
148+
identifier: "MT-980",
149+
attempt: 1,
150+
due_in_ms: 1_500,
151+
error: "error with \\nnewline"
152+
})
153+
],
154+
codex_totals: %{input_tokens: 0, output_tokens: 0, total_tokens: 0, seconds_running: 0},
155+
rate_limits: nil
156+
}}
157+
158+
rendered = render_snapshot(snapshot_data, 0.0)
159+
backoff_lines = rendered |> String.split("\n") |> Enum.filter(&String.contains?(&1, "MT-980"))
160+
161+
assert length(backoff_lines) == 1
162+
163+
[backoff_line] = backoff_lines
164+
165+
assert backoff_line =~ "error=error with newline"
166+
refute backoff_line =~ "\\n"
167+
end
168+
141169
test "snapshot fixture: unlimited credits variant" do
142170
snapshot_data =
143171
{:ok,

0 commit comments

Comments
 (0)