aws-sdk-net: AttributeValue of type L does not set IsLSet to true when the list is empty.
I’m using a DynamoDB stream record in a Lambda to move data from one table to another. The data from the stream is Dictionary<string, Amazon.DynamoDBv2.Model.AttributeValue>, which is the same data I need for a Amazon.DynamoDBv2.Model.PutRequest. The problem I’m seeing is that I receive a record that is of type L but IsLSet is false if L has no data.
Expected Behavior
IsLSet should be true if the data in DynamoDB is of type L, even if the list is empty.
Current Behavior
When a record stored in DynamoDB is a list (L) the IsLSet value is false when the list is empty.
Possible Solution
The code for IsLSet looks like this:
public bool IsLSet
{
get
{
return Amazon.Util.Internal.InternalSDKUtils.GetIsSet(this._l);
}
set
{
Amazon.Util.Internal.InternalSDKUtils.SetIsSet(value, ref this._l);
}
}
The problem with this is that the result of GetIsSet will always be false for an empty list (unless that list is an AlwaysSendList, which this is not, nor should it be).
It seems to me that the solution might be to set a flag when L’s setter is called and not base it on the existence of data in the list. Alternatively this._l could be null until it needs to not be null. If it is null the getter for L could return an empty list. The presence of a null this._l would be an indicator that L is not set, so IsLSet could return false.
Steps to Reproduce (for bugs)
Create a table in DynamoDB. Include an attribute with DynamoDB JSON like this:
"MyTestAttribute": {
"L": []
}
Hook up a Lambda stream to the data (presumably you can just query or scan the table for the record as well) and inspect the IsLSet property. It will be set to false when it should be true.
Context
This bug is making it such that I cannot use the streams to migrate data between tables without intimate knowledge of the data (which I’d like to avoid). Given that this can occur repeatedly inside of nested objects (type M) a work around is not particularly feasible.
Your Environment
- AWSSDK.Core version used: 3.3.24.3
- Service assembly and version used: AWSSDK.DynamoDBv2/3.3.10.3, Amazon.Lambda.DynamoDBEvents/1.0.1
.NET Core Info
- .NET Core version used for development: 2.1
- .NET Core version installed in the environment where application runs: 2.1
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 2
- Comments: 22 (7 by maintainers)
This is a big problem and not a difficult fix. I am deeply disappointed by the quality of this library. I keep finding so many trivial bugs that should have been fixed within hours of being reported yet it has been years and no real response. I’m to the point where I’m considering writing my own high-level client.
@jamesbascle I see, I understand the issue. I will bring this up to my team so we can re-prioritize this.
I don’t believe this has been fixed. I’m not heavily in the .Net space these days, but it’s still an issue.
Any status update on prioritization? My team encountered this bug again today.
We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.