taoensso / faraday

Amazon DynamoDB client for Clojure
https://www.taoensso.com/faraday
Eclipse Public License 1.0
238 stars 84 forks source link

batch-write-item failing for set with > 1 element #36

Closed uros-r closed 10 years ago

uros-r commented 10 years ago

Using faraday 1.4.0 against dynamodb-local.

(create-table client-opts :mytable [:id :n]
    {:throughput {:read 1 :write 1} :block? true})

(batch-write-item client-opts
    {:mytable {:put [{:id 1 :s #{"a" "b"}}]}})

Results in

AmazonServiceException Cannot perform multiple operations on the same item in a BatchWriteItem (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: 93d9cf35-a1a4-4ad1-bceb-bc0a192f17e8)  com.amazonaws.http.AmazonHttpClient.handleErrorResponse (AmazonHttpClient.java:805)

Whereas this works fine:

(far/batch-write-item client-opts
    {:mytable {:put [{:id 1 :s #{"a"}}]}})

And put-item requests also work for the example that fails with batch-write-item.

Finally, a Java implementation of the problematic BatchWriteItem request works fine (knocked up just to make sure it's not an obvious dynamodb-local problem).

ptaoussanis commented 10 years ago

Hi there,

I looked at this only very briefly - but it does look like a bug. Could you try v1.5.0-SNAPSHOT and see if it resolves the issue?

Thanks, cheers! :-)

uros-r commented 10 years ago

Confirming that the fix in dev / 1.5.0-SNAPSHOT works for me:

(batch-write-item client-opts {:mytable {:put [{:id 1 :s #{"a" "b" "c"}}]}})
=> {:unprocessed {}, :cc-units nil}

(get-item client-opts :mytable {:id 1})
=> {:id 1, :s #{"a" "b" "c"}}

Thanks for picking up so promptly! :)

ptaoussanis commented 10 years ago

Great, thanks for the confirmation. Just pushed v1.5.0 to Clojars: https://github.com/ptaoussanis/faraday/releases

Cheers!