tywalch/electrodb

Unspecified attribute which is used as a pk in a GSI is set to empty string on expression

Closed this issue · 3 comments

Describe the bug
For a table with a GSI which has pk/sk that map to non-required attributes (i.e a sparse index), calling put with an item that does not have the pk attribute specified but does have the sk attribute specified, ElectrobDb adds the pk attribute with an empty string value to the expression, which results in the error below.

The first Playground link below demonstrates this symptom. Note that code is not specified on the put object, but is set to empty string in the expression. The second Playground link shows that this does not happen if the sk attribute task is not set.

ElectroDB Version
2.5.1

ElectroDB Playground Link
ElectroDB Playground 1

ElectroDB Playground 2

Entity/Service Definitions
As in Playground

Expected behavior
If an attribute is not set on the object in the put request it should not be present in the expression

Errors

One or more parameter values are not valid. A value specified for a secondary index key is not supported. The AttributeValue for a key attribute cannot contain an empty string value

Thanks Paul! I think this one should actually be a pretty easy one -- I'll hopefully have updates soon

@PaulJNewell77 I have addressed this issue in version 2.8.2, let me know if that fixes your issue 👍

Feel free to reopen this issue if the issue wasn't resolved with 2.8.2