-
Notifications
You must be signed in to change notification settings - Fork 862
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
DynamoDB AttributeValue roundtrip of empty number or string sets #3297
Comments
I think it would make sense to align on the attribute value the SS, BS and NS property with corresponding |
In V4 the |
I understand that but we have this problem with 3.x |
Sorry I thought you were talking about V4. If you want to submit a PR to add the |
@normj why is this being treated as a feature and not a bug? It is currently not possible to roundtrip empty sets as outlined in the description. |
@normj I'm one of @danielmarbach's colleagues. I have raised #3299 which I hope properly implements your suggestion. |
@DavidBoike Your PR looks good. I'll try and get this out soon. @danielmarbach My logic was yes it is an architecture bug in the SDK with how SDK handles collections and the ability to know if a collection has a value or not. We are addressing the bug in V4 by changing the default of collections to be null. We aren't going to add |
Version I believe that solves this issue and closing the issue. |
Comments on closed issues are hard for our team to see. |
@normj I think this issue needs to be reopened. Using the latest SDK you pushed yesterday the service doesn't accept empty NS, BS or SS values. The simplest possible repro is: var client = new DynamoDBClient();
await client.BatchWriteItemAsync(new BatchWriteItemRequest(new Dictionary<string, List<WriteRequest>>
{
{
"SomeTable", [
new(new PutRequest(new Dictionary<string, AttributeValue>
{
{ "PK", new AttributeValue(Guid.NewGuid().ToString()) },
{ "SK", new AttributeValue(Guid.NewGuid().ToString()) },
{ "Data", new AttributeValue { NS = [], IsNSSet = true } }
}))
]
}
})); that blows with
Here is a PR that shows the same on our end |
@danielmarbach I should have remembered when you initially asked about adding the IsSet methods but on the service side it doesn't support empty sets for an AttributeValue. So the IsSet methods added probably have little value other then consistency. Here is the line from the PutItem API reference docs: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html#DDB-PutItem-request-Item
|
That to me, reads as they are allowed in the case above because I'm not using it as a PK or SK key nor do I have an index defined. Or in other words: This reads to me as empty values are allowed unless you use them as SK, PK or in an index. Can you clarify? |
@danielmarbach I think the doc is written confusingly joining 2 different restrictions. Sets and the other collection types can not even be used as the PK or SK. The line |
Describe the bug
When serializing content with empty Lists (
L
) or empty Maps (M
) it is possible to force those by manually settingIsLSet
orIsMSet
totrue
which then wraps things internally in anAlwaysSendList
orAlwaysSendDictionary
. This is necessary to allow setting list and map types to an empty value without running intoUnfortunately, it is not possible today to use empty string sets (
SS
), number sets (NS
) or binary sets (BS
) since they have no public way of enforcing something likeIsSSSet
. The SDK currently has equivalent internal methods that make a bunch of assumptions that seem incompatible with setting those sets to empty values.When you try to set any of these types to an empty set type, the following exception is thrown
Expected Behavior
Having the possibility to explicitly set/write sets of strings, sets of numbers or sets of binary data to empty.
Current Behavior
A
is thrown
Reproduction Steps
Set either SS, BS or NS to an empty list and try to write it against dynamodb.
Possible Solution
No response
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
Latest
Targeted .NET Platform
All
Operating System and version
All
The text was updated successfully, but these errors were encountered: