In testing, had found a client error ClientError as follows:
An error occurred (ValidationException) when calling the BatchWriteItem operation: One or more parameter values were invalid: An AttributeValue may not contain an empty string
However, if I immediately put the same item via the regular put_item method, it worked fine. I used the code straight out of the docs, as follows:
with ACCOUNTS_TABLE.batch_writer() as batch:
for item in items:
try:
batch.put_item(Item=item)
except ClientError as e:
print e.message
print item
ACCOUNTS_TABLE.put_item(Item=item)
print "successfully posted via regular put_item"
An error occurred (ValidationException) when calling the BatchWriteItem operation: One or more parameter values were invalid: An AttributeValue may not contain an empty string
{'acc_short_name': 'name', 'account_id': '000000000000', 'secrets': {'external_id_1': 'randomstring', 'external_id_2': 'randomstring'}, 'canonical_user_id': 'randomstring', 'environments': ['[null]', 'hub'], 'available_volumes_prune': True, 'regions': ['us-west-2'], 'client': 'client name', 'listed': True, 'acc_description': None}
successfully posted via regular put_item
After turning on debug logging on botocore, it turned out that in the background it was batching up all of the items, and even though the error came up with this specific item, it was actually a totally different item that in the batch that was causing the problem.
ClientError should have a two new attributes:
Marking as a feature request.
I'd also really appreciate a more useful error in this case or perhaps a way to access the current items in the batch so they can be logged out manually?
Most helpful comment
Marking as a feature request.