From a61932c4daabe04ccfc6f882fe9e21ad61e95f96 Mon Sep 17 00:00:00 2001 From: Coff0xc <184964491+Coff0xc@users.noreply.github.com> Date: Sat, 21 Nov 2026 19:54:18 +0000 Subject: [PATCH] fix(agent): keep LLM connection-test logs on one line The logged response body was inserted raw. A newline in that body became another log record. CR and LF are now spaces before the line is written. --- CHANGELOG.md | 1 + agent/clipbody_test.go | 16 ++++++++++++++++ agent/provider.go | 5 +++++ 3 files changed, 22 insertions(+) create mode 100644 agent/clipbody_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 5af6fb6..4a47e52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented in this file. The format is b ### Fixed +- **LLM connection-test logs stay one line**: the response body written by a connection test has CR and LF replaced with spaces before it is logged, so the body cannot start a second log record. - **Docker Compose database passwords with URL-special characters**: `docker-compose.yml` no longer pastes `POSTGRES_PASSWORD` into `ARTEX_PG_DSN`. The server builds the URL from `ARTEX_PG_HOST`, `ARTEX_PG_PORT`, `ARTEX_PG_USER`, `ARTEX_PG_PASSWORD`, `ARTEX_PG_DBNAME` and `ARTEX_PG_SSLMODE`, percent-encoding the user and password, so `/`, `?`, `%`, `@`, `:` and spaces connect. An explicit `ARTEX_PG_DSN` still wins and is not rewritten. `ARTEX_PG_PASSWORD` is removed from the environment with the other startup secrets (#450). ## [0.7.0] - 2026-11-21 diff --git a/agent/clipbody_test.go b/agent/clipbody_test.go new file mode 100644 index 0000000..21194ba --- /dev/null +++ b/agent/clipbody_test.go @@ -0,0 +1,16 @@ +package agent + +import ( + "strings" + "testing" +) + +func TestClipBodyFlattensNewlines(t *testing.T) { + got := clipBody("ok\r\ninjected log line\n") + if strings.Contains(got, "\n") || strings.Contains(got, "\r") { + t.Fatalf("clipBody kept a line break: %q", got) + } + if !strings.Contains(got, "injected log line") { + t.Fatalf("clipBody dropped the text: %q", got) + } +} diff --git a/agent/provider.go b/agent/provider.go index 96d39a6..088fcbb 100644 --- a/agent/provider.go +++ b/agent/provider.go @@ -602,6 +602,11 @@ func logTestConnection(c Config, capt *llmrec.Capture) { // the head of an SSE stream while bounding a runaway response. func clipBody(s string) string { s = strings.TrimSpace(s) + // One log record per attempt. A body that contains a newline would + // otherwise look like a second log line. + s = strings.ReplaceAll(s, "\r\n", " ") + s = strings.ReplaceAll(s, "\n", " ") + s = strings.ReplaceAll(s, "\r", " ") if s == "" { return "(empty)" }