Azure / Azure/azure-functions-dotnet-worker

Cosmos DB Bindings Doesn't go well with Newton Json with Cosmos DB Extension 4.0.0

Open
#1,272 14 comments 0 reactions 0 assignees View on GitHub
area: documentation
Dominant language
C#
Stars
466
Forks
215
Avg merge
3d 10h
Merged PRs (30d)
7

Description

Setting up Dto Property Name with Newton.Json Causes System.Core.PrivateLib Exception but If we setup Dto Property Name with System.Text.Json there's no issues at all.

**Logs:**
[2023-01-14T20:10:30.058Z] Executed 'Functions.StoreDataNewtonJson' (Failed, Id=d64be871-fa1f-415d-ad78-55db2f1b7125, Duration=6232ms)
[2023-01-14T20:10:30.060Z] System.Private.CoreLib: Exception while executing function: Functions.StoreDataNewtonJson. Microsoft.Azure.Cosmos.Client: Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 9a4a72af-7310-4944-896f-05aca0e304ff; Reason: (Message: {"Errors":["One of the specified inputs is invalid"]}
[2023-01-14T20:10:30.061Z] ActivityId: 9a4a72af-7310-4944-896f-05aca0e304ff, Request URI: /apps/DocDbApp/services/DocDbServer2/partitions/a4cb494e-38c8-11e6-8106-8cdcd42c33be/replicas/1p/, RequestStats:
[2023-01-14T20:10:30.061Z] RequestStartTime: 2023-01-14T20:10:29.9995688Z, RequestEndTime: 2023-01-14T20:10:30.0005439Z, Number of regions attempted:1
[2023-01-14T20:10:30.062Z] {"systemHistory":[{"dateUtc":"2023-01-14T20:09:33.7461822Z","cpu":4.570,"memory":13475416.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0393,"availableThreads":32766,"minThreads":12,"maxThreads":32767},"numberOfOpenTcpConnection":2},{"dateUtc":"2023-01-14T20:09:43.7471240Z","cpu":0.871,"memory":13463388.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0886,"availableThreads":32765,"minThreads":12,"maxThreads":32767},"numberOfOpenTcpConnection":2},{"dateUtc":"2023-01-14T20:09:53.7524550Z","cpu":1.419,"memory":13472224.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.039,"availableThreads":32766,"minThreads":12,"maxThreads":32767},"numberOfOpenTcpConnection":2},{"dateUtc":"2023-01-14T20:10:03.7581350Z","cpu":0.846,"memory":13845824.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0221,"availableThreads":32766,"minThreads":12,"maxThreads":32767},"numberOfOpenTcpConnection":2},{"dateUtc":"2023-01-14T20:10:13.7673388Z","cpu":1.118,"memory":13775372.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0441,"availableThreads":32766,"minThreads":12,"maxThreads":32767},"numberOfOpenTcpConnection":2},{"dateUtc":"2023-01-14T20:10:23.7855365Z","cpu":5.058,"memory":13416328.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0363,"availableThreads":32766,"minThreads":12,"maxThreads":32767},"numberOfOpenTcpConnection":2}]}
[2023-01-14T20:10:30.063Z] RequestStart: 2023-01-14T20:10:29.9995688Z; ResponseTime: 2023-01-14T20:10:30.0005439Z; StoreResult: StorePhysicalAddress: rntbd://127.0.0.1:10253/apps/DocDbApp/services/DocDbServer2/partitions/a4cb494e-38c8-11e6-8106-8cdcd42c33be/replicas/1p/, LSN: 28, GlobalCommittedLsn: -1, PartitionKeyRangeId: 0, IsValid: True, StatusCode: 400, SubStatusCode: 0, RequestCharge: 0, ItemLSN: -1, SessionToken: -1#28, UsingLocalLSN: False, TransportException: null, BELatencyMs: 0.219, ActivityId: 9a4a72af-7310-4944-896f-05aca0e304ff, RetryAfterInMs: , TransportRequestTimeline: {"requestTimeline":[{"event": "Created", "startTimeUtc": "2023-01-14T20:10:29.9995688Z", "durationInMs": 0.0059},{"event": "ChannelAcquisitionStarted", "startTimeUtc": "2023-01-14T20:10:29.9995747Z", "durationInMs": 0.0022},{"event": "Pipelined", "startTimeUtc": "2023-01-14T20:10:29.9995769Z", "durationInMs": 0.2442},{"event": "Transit Time", "startTimeUtc": "2023-01-14T20:10:29.9998211Z", "durationInMs": 0.4106},{"event": "Received", "startTimeUtc": "2023-01-14T20:10:30.0002317Z", "durationInMs": 0.1024},{"event": "Completed", "startTimeUtc": "2023-01-14T20:10:30.0003341Z", "durationInMs": 0}],"serviceEndpointStats":{"inflightRequests":1,"openConnections":1},"connectionStats":{"waitforConnectionInit":"False","callsPendingReceive":0,"lastSendAttempt":"2023-01-14T20:10:29.9341020Z","lastSend":"2023-01-14T20:10:29.9341020Z","lastReceive":"2023-01-14T20:10:29.9351360Z"},"requestSizeInBytes":532,"requestBodySizeInBytes":89,"responseMetadataSizeInBytes":177,"responseBodySizeInBytes":53};
[2023-01-14T20:10:30.064Z] ResourceType: Document, OperationType: Upsert
[2023-01-14T20:10:30.065Z] , SDK: Microsoft.Azure.Documents.Common/2.14.0, Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, Windows/10.0.22623 cosmos-netstandard-sdk/3.29.1);.

**Affected Version:**
Microsoft.Azure.Functions.Worker.Extensions.CosmosDB - "4.0.0"

**Working Version:**
Microsoft.Azure.Functions.Worker.Extensions.CosmosDB - "3.0.9"

**Sample Code:**
https://github.com/AathifMahir/CosmosBindingNewtonJsonIssue

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the sample repository linked in the issue and reproduce the behavior using Microsoft.Azure.Functions.Worker.Extensions.CosmosDB 4.0.0, comparing it with 3.0.9. Read the sample's DTO and Cosmos DB binding setup, then determine what test or reproduction confirms that Newtonsoft.Json and System.Text.Json behave consistently without the reported 400 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.