go-dynamock icon indicating copy to clipboard operation
go-dynamock copied to clipboard

aws-sdk-go's PutItem() never returns a nil pointer

Open danny-cheung opened this issue 5 years ago • 0 comments

I am testing that we gracefully handle conditional write errors.

In my particular case, write an item, but don't overwrite it if already exists.

  • Operation = PutItemWithContext()
  • Condition = attribute_not_exist(id)

If an object with the same id exists, aws-sdk-go will return an error and a pointer to a blank PutItemOutput object. https://github.com/aws/aws-sdk-go/blob/v1.36.19/service/dynamodb/api.go#L4382

Simulating an error in Dynamock, a nil PutItemOutput pointer is returned. https://github.com/gusaul/go-dynamock/blob/master/put_item.go#L69

This becomes a problem when wrapper libraries relies/assumes AWS's behaviour. e.g. https://github.com/guregu/dynamo/blob/master/put.go#L97-L101

danny-cheung avatar Jan 06 '21 05:01 danny-cheung