JSONHandler.Handle returns nil even when the write to stdout failed #22
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found during the adversarial review of
#21
(#21 (comment)). Pre-existing,
not introduced by that PR.
JSONHandler.Handlediscards the error from its write to stdout and returnsnilunconditionally.slog.Handler.Handleis declared to return anerrorprecisely so a failing sink can be reported; returning
niltellslog/slogthe record was delivered when it was not.
This surfaced in that review as a lint question — the line is written
_, _ = fmt.Fprintln(...), which a newer golangci-lint flags and the repo'spinned linter does not. Silencing the linter is not the fix and would bury the
defect. The defect is that a log line can vanish with nothing reporting it.
Definition of done
Handlerather than discarded, inevery handler that writes to a sink, not only
JSONHandler.failing must not silently suppress delivery to its siblings, and the caller
must still learn that something failed.
reaches the caller. This requires the sink to be injectable; if it is not
today, make it so rather than skipping the test.
descriptions, since "logging can fail and here is how you find out" is
caller-facing behaviour.
Implementation requirements
logpackage: that is thev1.0.0deadlock in #18, andTestJSONHandlerDeadlockguards it.(closes #<this issue>).