Skip to content

fix: avoid panic on typed nil errors with nilable kinds - #844

Open
CJstate wants to merge 1 commit into
rs:masterfrom
CJstate:fix/typed-nil-nilable-error
Open

CJstate wants to merge 1 commit into
rs:masterfrom
CJstate:fix/typed-nil-nilable-error

Conversation

@CJstate

@CJstate CJstate commented Nov 29, 2026

Copy link
Copy Markdown

isNilValue only checked reflect.Ptr, so an error implemented on a
nilable non-pointer type (e.g. a func type with an Error() method) slipped
through and AnErr/Err/Fields called Error() on a nil receiver,
panicking. Handle all nilable reflect kinds and the nil interface case.

Regression test: TestEvent_AnErrWithTypedNilFuncError panics before the fix.

Signed-off-by: CJstate <142857225+CJstate@users.noreply.github.com>

@atishay-kasliwal atishay-kasliwal left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a nil func-typed error whose Error() calls the func, master panicked in AnErr, Err and Fields; here they log without the error (Fields writes null). Nil map and slice error types are now skipped like nil pointers were, and non-nil errors are unchanged.

This branch has not been deployed

No deployments
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.

2 participants