Changing default CosmosSerializationOptions to camelCase causes an exception in CosmosDB SDK V4
See original GitHub issueDescribe the bug I have a problem with a CosmosDB SDK V4.0.0-preview3. When I try to change default CosmosSerializationOptions it causes an exception when I try to use GetItemQueryIterator. Everything else except this method works fine.
To Reproduce
var client = new CosmosClientBuilder(connectionString)
.WithSerializerOptions(new CosmosSerializationOptions { PropertyNamingPolicy = CosmosPropertyNamingPolicy.CamelCase })
.Build();
var container = client.GetContainer("SocialNetwork", "Posts");
var query = new QueryDefinition("SELECT * FROM c");
await foreach (var item in container.GetItemQueryIterator<Post>(query))
{
Console.WriteLine(item);
}
Actual behavior Exception message:
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'source')
at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Azure.Cosmos.CosmosResponseFactory.CreateQueryFeedResponseWithSerializer[T](Response cosmosResponseMessage, CosmosSerializer serializer)
at Azure.Cosmos.CosmosResponseFactory.CreateQueryFeedResponse[T](Response cosmosResponseMessage)
at Azure.Cosmos.PageIteratorCore`1.GetPageAsync(String continuation, CancellationToken cancellationToken)
at Azure.Cosmos.PageResponseEnumerator.FuncAsyncPageable`1.AsPages(String continuationToken, Nullable`1 pageSizeHint)+MoveNext()
at Azure.Cosmos.PageResponseEnumerator.FuncAsyncPageable`1.AsPages(String continuationToken, Nullable`1 pageSizeHint)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
at Azure.AsyncPageable`1.GetAsyncEnumerator(CancellationToken cancellationToken)+MoveNext()
at Azure.AsyncPageable`1.GetAsyncEnumerator(CancellationToken cancellationToken)+MoveNext()
at Azure.AsyncPageable`1.GetAsyncEnumerator(CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
at ConsoleAppCosmosDb.Program.Main(String[] args) in C:\Users\XPS\source\repos\ConsoleAppCosmosDb\ConsoleAppCosmosDb\Program.cs:line 29
at ConsoleAppCosmosDb.Program.Main(String[] args) in C:\Users\XPS\source\repos\ConsoleAppCosmosDb\ConsoleAppCosmosDb\Program.cs:line 29
at ConsoleAppCosmosDb.Program.<Main>(String[] args)
If I remove this option or change CamelCase to Default everything works.
Environment summary SDK Version: 4.0.0-preview3 OS Version: Windows 10
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:8 (5 by maintainers)
Top Results From Across the Web
azure - Changing default CosmosSerializationOptions to ...
I have a problem with a CosmosDB SDK V4.0.0-preview3. When I try to change default CosmosSerializationOptions it causes an exception when I try ......
Read more >Changing default CosmosSerializationOptions to camelCase ...
Coding example for the question Changing default CosmosSerializationOptions to camelCase causes an exception in CosmosDB SDK V4.
Read more >Custom JSON serialization with Azure Cosmos DB SDK
This post explains how you can use custom JSON serializer settings with Cosmos DB using Newtonsoft JSON and System.Text.Json.
Read more >Manage consistency levels in Azure Cosmos DB
Learn how to configure and manage consistency levels in Azure Cosmos DB using Azure portal, .NET SDK, Java SDK and various other SDKs....
Read more >Persisting Cloud Events to Cosmos DB in Azure
In .NET 5, the default validation has changed, with all properties required by default. This is a careless change and one that's going...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was playing with an idea. I often use preview when I know the timeline is considerably into the future. I was also hoping to use just one serializer across the project. In the end, the name preview3 made me think v4 was closer to a release than it is.
@eskaufel I understand the concern, currently V4 is an experimental version, not meant for production usage, and the efforts are mainly put to harden and improve V3, which acts as a base of V4. There is no ETA for V4 GA.
Since V4 is only experimental and preview, why are you currently using it? Are you doing some POC? Why not use V3 SDK instead? What are the reasons you are currently using V4?