Read queue depths with Find, not Scan (closes #234) #237

Merged
clawbot merged 1 commits from issue-234-queue-depth-no-gorm-scan into next 2026-08-20 07:55:20 +02:00

1 Commits

Author SHA1 Message Date
clawbot
354b271d35 Read queue depths with Find, not Scan (closes #234)
All checks were successful
check / check (push) Successful in 3m22s
(*gorm.DB).Scan swaps GORM's own traceRecorder in for the configured
logger for the duration of the statement, and that recorder does not
implement gorm.ParamsFilter. The statement therefore reaches the log
with its bound values interpolated, which is the one path
(*gormlog.Logger).ParamsFilter cannot reach. internal/gormlog's
scan_guard_test.go exists to keep that path out of production code;
the queue-depth sampler landed with two calls on it, so next has been
failing make check on its own.

Both call sites now use Find, which goes through the normal query
callback. The emitted SQL is otherwise unchanged -- callbacks.Query
and callbacks.RowQuery share BuildQuerySQL, and both call sites set
Model and Select explicitly, so the table, the column list and the
soft-delete clause are built identically. Only the log line differs:

  Scan: ... WHERE status IN ("pending","retrying") AND ...
  Find: ... WHERE status IN (?,?) AND ...

TestQueueDepthSample_LogsNoBoundValue drives one sample through the
adapter and asserts the aggregate keeps its placeholders and carries
no status literal. Restoring either Scan fails it as well as the
static guard.

database.NewTestWebhookDBManagerWithLogger lets that test capture the
SQL the per-webhook databases emit; NewTestWebhookDBManager keeps its
signature and delegates to it.
2026-08-20 05:41:55 +00:00