From 53f2ead6586c95d167ba222bd7eab5394e53c338 Mon Sep 17 00:00:00 2001 From: sneak Date: Thu, 15 Oct 2026 15:41:18 +0000 Subject: [PATCH] Say the query logger drops bound values (closes #535) The comment on MaxAccessLogLineBytes said the GORM adapter logs each statement with the client's parameter written into it. Its ParamsFilter drops every bound value, so the statement is logged with its placeholders. The comment now says so and keeps the parts that still hold: the widest line spends two budgets and the adapter's test checks it against this constant. The assertBounded doc no longer claims each line was cut, and the postReceiver doc no longer explains itself by a log size test that is gone. Model: opus-5-5 --- internal/gormlog/gormlog_test.go | 2 +- internal/handlers/logbound_test.go | 7 +++---- internal/middleware/middleware.go | 14 +++++++------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/internal/gormlog/gormlog_test.go b/internal/gormlog/gormlog_test.go index 65b216c..a149ead 100644 --- a/internal/gormlog/gormlog_test.go +++ b/internal/gormlog/gormlog_test.go @@ -146,7 +146,7 @@ func openDB( } // assertBounded holds every line the adapter wrote to the stated -// ceiling and proves each was cut rather than merely short. +// ceiling and proves no line carried a whole client value. func assertBounded(t *testing.T, out string) { t.Helper() diff --git a/internal/handlers/logbound_test.go b/internal/handlers/logbound_test.go index 9d35dac..2072599 100644 --- a/internal/handlers/logbound_test.go +++ b/internal/handlers/logbound_test.go @@ -191,13 +191,12 @@ func receiverRouter(h *handlers.Handlers) *chi.Mux { return router } -// postReceiver sends one POST at /h/. +// postReceiver sends one POST with an empty body at /h/ +// through router and returns the response status. // // RawPath is cleared after parsing so chi routes on the decoded path // and the handler sees the raw bytes rather than their percent-escaped -// spelling. That is the harder case for the budget: the escaped -// spelling is plain ASCII, which costs one byte per byte, while the -// decoded bytes are what the log handler has to escape. +// spelling. func postReceiver( t *testing.T, router *chi.Mux, segment string, ) int { diff --git a/internal/middleware/middleware.go b/internal/middleware/middleware.go index 9b5b842..5b4a8c2 100644 --- a/internal/middleware/middleware.go +++ b/internal/middleware/middleware.go @@ -118,13 +118,13 @@ const ( // a caller on a parameterised route would supply, which is the // only way those caps can be pinned at all. // - // One writer in that set is not a handler's own slog call. The - // GORM adapter in internal/gormlog logs the statement with the - // client-chosen parameter already interpolated into it, which on - // the receiver and login lookups is exactly the value the budgets - // above exist for. Its widest line spends two logfield.MaxBytes - // budgets — the statement and the driver error — against a fixed - // portion smaller than this one's, and + // The GORM adapter in internal/gormlog writes through slog as well, + // though not from a handler. It logs each statement with its + // placeholders rather than the values bound to them (see its + // ParamsFilter), so the key a client sends to the receiver or login + // lookup does not reach its lines. Its widest line spends two + // logfield.MaxBytes budgets — the statement and the driver error — + // against a fixed portion smaller than this one's, and // internal/gormlog/gormlog_test.go asserts every line it emits // against this constant directly rather than leaving it as // arithmetic.