diff --git a/Microsoft.Azure.Cosmos/src/Encryption/EncryptionProcessor.cs b/Microsoft.Azure.Cosmos/src/Encryption/EncryptionProcessor.cs index da39bddbd0..4c9d750df4 100644 --- a/Microsoft.Azure.Cosmos/src/Encryption/EncryptionProcessor.cs +++ b/Microsoft.Azure.Cosmos/src/Encryption/EncryptionProcessor.cs @@ -117,7 +117,14 @@ public async Task DecryptAsync( return input; } - JObject itemJObj = EncryptionProcessor.baseSerializer.FromStream(input); + JObject itemJObj; + using (StreamReader sr = new StreamReader(input, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 1024, leaveOpen: true)) + { + using (JsonTextReader jsonTextReader = new JsonTextReader(sr)) + { + itemJObj = JsonSerializer.Create().Deserialize(jsonTextReader); + } + } JProperty encryptionPropertiesJProp = itemJObj.Property(Constants.Properties.EncryptedInfo); JObject encryptionPropertiesJObj = null; diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/EncryptionTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/EncryptionTests.cs index 6f480d757c..77686d08ef 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/EncryptionTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/EncryptionTests.cs @@ -177,6 +177,17 @@ await EncryptionTests.IterateDekFeedAsync( } } + [TestMethod] + public async Task EncryptionCreateItemWithoutEncryptionOptions() + { + TestDoc testDoc = TestDoc.Create(); + ItemResponse createResponse = await EncryptionTests.containerCore.CreateItemAsync( + testDoc, + new PartitionKey(testDoc.PK)); + Assert.AreEqual(HttpStatusCode.Created, createResponse.StatusCode); + Assert.AreEqual(testDoc, createResponse.Resource); + } + [TestMethod] public async Task EncryptionCreateItem() { diff --git a/changelog.md b/changelog.md index d42d318923..ec90de7acf 100644 --- a/changelog.md +++ b/changelog.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#1213](https://github.com/Azure/azure-cosmos-dotnet-v3/pull/1213) CosmosException now returns the original stack trace. - [#1213](https://github.com/Azure/azure-cosmos-dotnet-v3/pull/1213) ResponseMessage.ErrorMessage is now always correctly populated. There was bug in some scenarios where the error message was left in the content stream. +- [#1242](https://github.com/Azure/azure-cosmos-dotnet-v3/pull/1242) Client encryption - Fix bug in read path without encrypted properties ## [3.7.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.7.0-preview) - 2020-02-25