Skip to content

Log call renders the key ID as %!(EXTRA string=...) instead of a field #118

Description

@linkdata

Summary

A structured-log call passes the key ID as a bare positional argument, so it is
rendered into the message as a formatting artefact instead of a field.

app/upbridge/upbridge.go:98:

ub.log.Info("Key not found in cache, contacting nodeman", keyID)

Observed output:

{"level":"INFO","msg":"Key not found in cache, contacting nodeman%!(EXTRA string=edge-receiver-01.edge.test)"}

The node name ends up glued to the message text, so it cannot be filtered or
indexed as a field, and the %!(EXTRA ...) marker leaks into logs.

Reproduction

mqtt-bridge abe75e1. Run the bridge in up mode with Debug = true and
publish a signed message from a node whose key is not yet cached; the line
appears on the first message from each node.

Expected behaviour

The key ID should be a named attribute, matching the other calls in the package.

Suggested fix

-ub.log.Info("Key not found in cache, contacting nodeman", keyID)
+ub.log.Info("Key not found in cache, contacting nodeman", "key_id", keyID)

Worth a quick grep for other odd-argument logging calls at the same time; go vet does not catch this for slog, but sloglint or staticcheck's
SA1029-adjacent checks can.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggoPull requests that update go codegood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions