Azure-cosmos-dotnet-v2: Create DocumentClient with TypeNameHandling.All causes StoredProc execution to fail when passing parameters

Created on 7 Aug 2018  路  1Comment  路  Source: Azure/azure-cosmos-dotnet-v2

NuGet Package: Microsoft.Azure.DocumentDB.Core (1.9.1)

Changing JsonSerializerSettings supplied to DocumentClient can cause StoredProc execution to fail.

Specifying TypeNameHandling.All causes multiple arguments to be passed as a _single object containing an array_, instead of as a _raw array_ when using the default serializer settings or TypeNameHandling.Auto.

As SerializerSettings are often specified for controlling how documents are formatted for storage in CosmosDB and typically not for how parameters are passed to CosmosDB StoredProcs - which should be consistent in all cases - this creates a fragile CosmosDB Client behaviour.

The output from the attached demo is:

TypeNameHandling.All arg count : 0 (Expected 3)
ScriptLog: undefined

TypeNameHandling.Auto arg count: 3 (Expected 3)
ScriptLog: arg1

Fiddler traces show parameters are passed as follows in the two scenarios:

TypeNameHandling.All: {"$type":"System.String[], System.Private.CoreLib","$values":["arg1","arg2","arg3"]}

TypeNameHandling.Auto (or default): ["arg1","arg2","arg3"]

StoredProcParameterDemo.zip

Most helpful comment

We're also affected by this. It looks like the CosmosDB Client shouldn't use the provided SerializerSettings for StoredProc parameters, but it's own SerializerSettings instead.

>All comments

We're also affected by this. It looks like the CosmosDB Client shouldn't use the provided SerializerSettings for StoredProc parameters, but it's own SerializerSettings instead.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

christian-vorhemus picture christian-vorhemus  路  5Comments

matthewacme picture matthewacme  路  4Comments

eiriktsarpalis picture eiriktsarpalis  路  5Comments

bowen5 picture bowen5  路  4Comments

wingfeng picture wingfeng  路  8Comments