Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PutItem nil pointer dereference #32

Open
NickLarsenNZ opened this issue Sep 22, 2020 · 0 comments
Open

PutItem nil pointer dereference #32

NickLarsenNZ opened this issue Sep 22, 2020 · 0 comments

Comments

@NickLarsenNZ
Copy link

I've come across a bug and thought I'd create an issue in case anyone else hits it.

mock.ExpectPutItem().ToTable(test_table).WithItems(map[string]*dynamodb.AttributeValue{
	"Provider": {S: aws.String("aws")},
	"ETag":     {S: aws.String(`W/"3fd5cf340c5e30202eca209855b7544a"`)},
	"Version":  {S: aws.String(`v3.7.0`)},
}).WillReturns(dynamodb.PutItemOutput{
	Attributes: map[string]*dynamodb.AttributeValue{
		"Provider": {S: aws.String("aws")},
		"ETag":     {S: aws.String(`W/"3fd5cf340c5e30202eca209855b7544a"`)},
		"Version":  {S: aws.String(`v3.7.0`)},
	},
})

I get:

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1579ecd]

goroutine 22 [running]:
testing.tRunner.func1.1(0x1645200, 0x1d9ddb0)
        /usr/local/go/src/testing/testing.go:940 +0x2f5
testing.tRunner.func1(0xc000263320)
        /usr/local/go/src/testing/testing.go:943 +0x3f9
panic(0x1645200, 0x1d9ddb0)
        /usr/local/go/src/runtime/panic.go:969 +0x166
github.com/gusaul/go-dynamock.(*MockDynamoDB).PutItem(0xc0000b3a40, 0xc0000ccbe0, 0x16eadc0, 0x7, 0xc0002d10d8)
        /Users/nick/go/pkg/mod/github.com/gusaul/[email protected]/put_item.go:36 +0x7d
data_processing.(*ProviderFeedService).CheckForNewVersions(0xc00010ff30, 0x16e7f84, 0x3, 0x1710696, 0x4b, 0x0, 0x0, 0x0, 0x0, 0x0)

Running a debug, I see *input.Table is nil, so an error is never returned.

image

It appears I provided the wrong input, but expected a graceful error rather than a panic.

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

No branches or pull requests

1 participant