From 8d0580582aa3c3ea0fc03e9af8286e07e202d7d9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 20 Jul 2026 17:16:27 +0000 Subject: [PATCH] Remove dead nil guards and unreachable else branch in jsonl_logger.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The withGlobalLogger helper already guarantees a non-nil logger before invoking any callback (see global_helpers.go:127). The nil guard checks inside the LogDifcFilteredItem and LogUnrecognizedEndpointPassthrough callbacks were therefore dead code — they could never be reached. Also simplify json.Marshal for JSONLUnrecognizedEndpointPassthrough: the struct has only string fields, so marshaling cannot fail. Replace the if/else error pattern with b, _ := json.Marshal(entry) to match similar patterns elsewhere (e.g. rpc_logger.go). These changes are consistent with all other withGlobalLogger callbacks in the package (rpc_logger.go, observed_url_domains_logger.go) which do not include redundant nil guards. Coverage improvement: LogDifcFilteredItem 88.9% → 100%, LogUnrecognizedEndpointPassthrough 75% → 100% Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- internal/logger/jsonl_logger.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/internal/logger/jsonl_logger.go b/internal/logger/jsonl_logger.go index 6b42b2efd..1863dd3d7 100644 --- a/internal/logger/jsonl_logger.go +++ b/internal/logger/jsonl_logger.go @@ -191,9 +191,6 @@ func LogDifcFilteredItem(entry *JSONLFilteredItem) { entry.Event = "difc_filtered" entry.Schema = difcSchemaV2 withGlobalLogger(&globalJSONLMu, &globalJSONLLogger, func(logger *JSONLLogger) { - if logger == nil { - return - } _ = logger.logEntry(entry) }) } @@ -211,16 +208,10 @@ func LogUnrecognizedEndpointPassthrough(method, path string) { Note: "Endpoint not in route table or metadata allowlist -- forwarded with no integrity and no secrecy labels", } - if b, err := json.Marshal(entry); err == nil { - LogWarnToMarkdown("proxy", "[UNRECOGNIZED-ENDPOINT] %s", string(b)) - } else { - LogWarnToMarkdown("proxy", "failed to marshal unrecognized endpoint event for %s %s: %v", method, path, err) - } + b, _ := json.Marshal(entry) + LogWarnToMarkdown("proxy", "[UNRECOGNIZED-ENDPOINT] %s", string(b)) withGlobalLogger(&globalJSONLMu, &globalJSONLLogger, func(logger *JSONLLogger) { - if logger == nil { - return - } _ = logger.logEntry(entry) }) }