Azure / azure-cosmosdb-java

Java Async SDK for SQL API of Azure Cosmos DB
MIT License
54 stars 61 forks source link

Error inserting document with a partition key of >100 bytes #56

Closed marmyr closed 6 years ago

marmyr commented 6 years ago

Made a PoC for it at https://github.com/marmyr/cosmos-bug-poc

But in short, this will reproduce the issue: ` private static class DummyObject { public final String partitionKey; public final String id; public final Integer ttl;

    public DummyObject(String partition, String id, int ttl) {
        this.partitionKey = partition;
        this.id = id;
        this.ttl = ttl;
    }

    String partition = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        DummyObject lock = new DummyObject(partition, UUID.randomUUID().toString(), 30);
        client.createDocument(collection.getSelfLink(), lock, null, true);`

com.microsoft.azure.documentdb.DocumentClientException: Message: {"Errors":["PartitionKey extracted from document doesn't match the one specified in the header"]}

moderakh commented 6 years ago

@marmyr thanks for reporting this. I think you are right. (This is a SDK issue). We will fix this for the next SDK release. For now if possible please use partition key with length less than 100 bytes.

moderakh commented 6 years ago

Addressed in 2.1.0 release.