From ac516103321633d757bd166d3d5512d78a85c6ba Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Fri, 20 Mar 2026 11:34:06 -0400 Subject: [PATCH] fix(agent): downgrade script completion error log to warn (#23369) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Downgrades the "reporting script completed" log in `agentscripts` from ERROR to WARN. During agent reconnects, the `scriptCompleted` RPC can race with the connection teardown, producing a "connection closed" error. Since `slogtest` treats ERROR logs as test failures, this causes `TestAgent_ReconnectNoLifecycleReemit` to flake on macOS. A failed timing report is non-fatal — the script itself has already finished, and the agent will continue operating normally. WARN is the appropriate severity, consistent with the call site in `agent.go:createDevcontainer`. Also switches from `fmt.Sprintf` to structured `slog.Error` fields for consistency with the rest of the codebase. Fixes coder/internal#1410 --- agent/agentscripts/agentscripts.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/agent/agentscripts/agentscripts.go b/agent/agentscripts/agentscripts.go index 333f0aca8e..e3de3855cf 100644 --- a/agent/agentscripts/agentscripts.go +++ b/agent/agentscripts/agentscripts.go @@ -398,11 +398,11 @@ func (r *Runner) run(ctx context.Context, script codersdk.WorkspaceAgentScript, }, }) if err != nil { - logger.Error(ctx, fmt.Sprintf("reporting script completed: %s", err.Error())) + logger.Warn(ctx, "reporting script completed", slog.Error(err)) } }) if err != nil { - logger.Error(ctx, fmt.Sprintf("reporting script completed: track command goroutine: %s", err.Error())) + logger.Warn(ctx, "reporting script completed: track command goroutine", slog.Error(err)) } }()