aws-sdk-java: Empty attribute values cannot be added to a DynamoDB table
Adding the following document to a DynamoDB table:
{
"id_str": "1",
"foo": ""
}
gives the following error:
One or more parameter values were invalid: An AttributeValue may not contain an empty string (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: HPH1B0TUMQKHF0Q7SOMEOR5CKJVV4KQNSO5AEMVJF66Q9ASUAAJG)
This is a common use case and already fixed for https://github.com/aws/aws-sdk-js/pull/1283#issuecomment-306954767[JavaScript SDK]. It has caused enough frustration among customers. This is evident at https://forums.aws.amazon.com/thread.jspa?threadID=90137&start=0&tstart=0 and https://news.ycombinator.com/item?id=13170746 and should be fixed.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 21
- Comments: 23 (4 by maintainers)
Commits related to this issue
- fixing changes when object have null strings https://github.com/aws/aws-sdk-java/issues/1189 — committed to tapasvimoturu/dynamite by deleted user 8 years ago
- Fix the function `save_video` to replace empty strings with `None`. DynamoDB does not accept objects with an empty string in its attribute. See, e.g., https://github.com/aws/aws-sdk-java/issues/1189 — committed to swen128/vhub by swen128 7 years ago
I’ve heard back from the DynamoDB team. They plan on supporting empty string sometime in 2018, no specific dates at the moment though. I’ll update this issue if I get more information.
I find it unacceptable that a database like this doesn’t support empty strings or native floats, (you have to convert them to Decimal).
It is already 2020 and I cannot believe aws still does not support empty string. Is this function in the plan or you guys just don’t care? Please give us an answer here. Thank you.
any update? still waiting 😦
We just started with DynamoDB and there you go, SURPRISE! I agree that empty doesn’t make great sense in NoSQL but it would really help customers and would love to know if this has come to any fix after a year and a half wait time.
Same here. const documentClient = new AWS.DynamoDB.DocumentClient({convertEmptyValues: true}) works for me.
any update?
@shorea Any update on this? What I experienced is that if I have optional values on my request payload, DynamoDB populates a digit into the values on retrieval. This lead to the inability to retrieve all the values from DynamoDB on my GET requests due to parsing errors originating from the values DynamoDB was populating the optional fields with. So I resolved to provide a default value whenever a field value is not supplied when saving data to DynamoDB. However, a solution to enable storing of empty strings, especially when the field is optional will be awesome.
I have still not found a solution. Just another entry into my “Why I never want to use AWS” list. So I created this:
It is far from perfect but it works.
Hello @shorea, Any update on when this would be supported?
DynamoDb now supports empty string values for non-key attributes: https://aws.amazon.com/about-aws/whats-new/2020/05/amazon-dynamodb-now-supports-empty-values-for-non-key-string-and-binary-attributes-in-dynamodb-tables/
I’ve reached out to the DynamoDB organization again regarding this issue.
DynamoDB is aware of the requirement and is still considering a fix for the issue. We know this response isn’t particularly satisfying, since the issue has been open for such a long time.
This should be a quick and easy thing to fix on the DynamoDB side. Where are the AWS pros at!?
This makes it so that you can not have any optional fields… any work arounds or answers?
Ah I see, I am not crazy about the idea of adding a flag to ignore empty strings and treat them as null. We did something similar for the DDB mapper and it’s surprising, possibly dangerous behavior since null and empty string do not have the same semantics and we are subtly hiding a service side limitation. That said an opt in approach seems reasonable. I’ve reached out to the service team to see if it’s possible to relax the constraint on empty string as I think that would be the best solution, I’ll let you know what I hear and we can go from there.
use update list to update the empty array
@VladMasarik Yeah still waiting I use the same for my appsync resolver in VTL land
Still a crappy work around as in the front end I need to find if null and then equate it to “” to make my tables work correctly
+1