Skip to content

oopsError context causes panics when with contains a nil ptr #48

@johan-madden

Description

@johan-madden

oopsError.Context() causes panics when with contains a nil ptr

	var id *int
	err := oops.With("id", id).Errorf("myError")

	if oopsError := errors.As(err, &oops.OopsError{}); oopsError {
		oopsError.Context()
	}

This will give panic: reflect: call of reflect.Value.Interface on zero Value and can cause error logs to panic and a lost error message and stacktrace.

For example with logrus.WithError(err).Error("Error")

Maybe the error is in kv.go dereferencePointers and need a check that the elem CanInterface?

			elem := val.Elem()
			if elem.CanInterface() {
				data[key] = elem.Interface()
			} else {
				data[key] = elem // not sure here
			}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions