Skip to content

Some kinds of errors are returned as %!s(PANIC=...nil pointer #96

@dirkmc

Description

@dirkmc

As described in filecoin-project/boost#1193 when go-jsonrpc encounters some errors it turns them into %!s(PANIC=...nil pointer

lotus users have encountered this error message when making API calls that time out:

ERROR: %!s(PANIC=Error method: runtime error: invalid memory address or nil pointer dereference)

The error message is printed out by lotus cli helper when an error is returned from a CLI Action:

fmt.Fprintf(os.Stderr, "ERROR: %s\n\n", err)

The format of the error message %!s(PANIC=...nil pointer indicates that fmt.Fprintf encountered a nil pointer when trying to call the Error() method on the golang error object that was passed to it. This is most likely because the error object wraps a nil error. An example golang Test that reproduces this behaviour:

type myerr struct {
	err error
}

func (e *myerr) Error() string {
	// if e.err is nil, this will panic
	return e.err.Error()
}

func TestPrintErr(t *testing.T) {
	fmt.Printf("%s\n", &myerr{})
}

=== RUN   TestPrintErr
%!s(PANIC=Error method: runtime error: invalid memory address or nil pointer dereference)
--- PASS: TestPrintErr (0.00s)

It looks like the underlying implementation of go-jsonrpc is returning an error object that wraps a nil error. My best guess is that this bug was introduced in #72

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions