Skip to content

event: restore Err() logging when ErrorStackMarshaler returns nil#763

Merged
rs merged 1 commit into
rs:masterfrom
alliasgher:fix-err-stack-nil
Apr 20, 2026
Merged

event: restore Err() logging when ErrorStackMarshaler returns nil#763
rs merged 1 commit into
rs:masterfrom
alliasgher:fix-err-stack-nil

Conversation

@alliasgher
Copy link
Copy Markdown
Contributor

Fixes #762. Commit f6fbd33 introduced a 'case nil: return e' that drops the error field entirely when ErrorStackMarshaler returns nil. This restores the original behaviour of always calling AnErr even when no stack is attached.

Commit f6fbd33 added `case nil: return e` in Event.Err() so that when
ErrorStackMarshaler returns nil (the error has no stack trace), the
function returns early without logging the error itself.

This was a regression. The previous behaviour was to fall through the
switch and always call AnErr(ErrorFieldName, err), ensuring the error
message is logged even when no stack is attached.

Libraries such as elastic/ecs-logging-go-zerolog (and plain fmt.Errorf
errors) rely on the old behaviour: calling Stack().Err(err) should
always log the error field; the stack field is additional and optional.

Change the `nil` case from `return e` to a comment (fall-through) so
that AnErr is called unconditionally. Update the test that was written
to match the incorrect behaviour.

Fixes rs#762

Signed-off-by: alliasgher <alliasgher123@gmail.com>
@IDisposable
Copy link
Copy Markdown
Contributor

This one only reverts one of the changes, probably should prefer #758

@rs rs merged commit 116c806 into rs:master Apr 20, 2026
5 checks passed
peiman added a commit to peiman/vaultmind that referenced this pull request Apr 22, 2026
Patch-level bug fix: restore Err() logging when ErrorStackMarshaler
returns nil (rs/zerolog#763).

task check: all 23 green. Addresses 1 of 2 updates in dependabot #13;
hugot 0.7.0 → 0.7.1 remains deferred (unexports Preprocess/Forward which
breaks BGE-M3).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Behavior change on Event.Err with commit f6fbd33

3 participants