question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting "One of the specified inputs is invalid" when trying `PatchItemAsync`

See original GitHub issue

We are continuously addressing and improving the SDK, if possible, make sure the problem persist in the latest SDK version.

Describe the bug Getting an unspecific error message when trying to PATCH a document/item.

To Reproduce

/*
{
    "id": "deee869b-4134-4546-9c96-dd06dac3acee",
    "name": "Demo",
    "_rid": "K4dvAIClggAEAAAAAAAAAA==",
    "_self": "dbs/K4dvAA==/colls/K4dvAIClggA=/docs/K4dvAIClggAEAAAAAAAAAA==/",
    "_etag": "\"010002d3-0000-0c00-0000-6114d2bd0000\"",
    "_attachments": "attachments/",
    "_ts": 1628754621
}
*/
var id = Guid.Parse("deee869b-4134-4546-9c96-dd06dac3acee");
var response = await container.PatchItemAsync<T>(id.ToString(), PartitionKey.None, new[] { PatchOperation.Replace("/name", "New Name") });

Expected behavior Expected response.Resource.Name to be “New Name” and that the item was updated in the collection.

Actual behavior Got BadRequest (400) - “One of the specified inputs is invalid”

Environment summary SDK Version: 3.20.1-preview OS Version (e.g. Windows, Linux, MacOSX): Windows 11

Additional context 👀 Not part of the private preview program

Additional context might be found in #1513

Microsoft.Azure.Cosmos.CosmosException : Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: a8a9b0be-2ea9-44cd-929a-2a2a563a3ec7; Reason: (Message: {"Errors":["One of the specified inputs is invalid"]}
      ActivityId: a8a9b0be-2ea9-44cd-929a-2a2a563a3ec7, Request URI: /apps/6fad0193-c081-450a-901b-66645e3f2bb7/services/4022c78c-10d9-49ab-b1c2-9f78840d0156/partitions/6926c955-dd64-4048-8d0f-de760a044e23/replicas/132732738128202883p/, RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Windows/10.0.22000 cosmos-netstandard-sdk/3.19.3);
         at Microsoft.Azure.Documents.StoreResult.ToResponse(RequestChargeTracker requestChargeTracker)
         at Microsoft.Azure.Documents.ConsistencyWriter.WritePrivateAsync(DocumentServiceRequest request, TimeoutHelper timeout, Boolean forceRefresh)
         at Microsoft.Azure.Documents.BackoffRetryUtility`1.ExecuteRetryAsync(Func`1 callbackMethod, Func`3 callShouldRetry, Func`1 inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action`1 preRetryCallback)
         at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException)
         at Microsoft.Azure.Documents.BackoffRetryUtility`1.ExecuteRetryAsync(Func`1 callbackMethod, Func`3 callShouldRetry, Func`1 inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action`1 preRetryCallback)
         at Microsoft.Azure.Documents.ConsistencyWriter.WriteAsync(DocumentServiceRequest entity, TimeoutHelper timeout, Boolean forceRefresh, CancellationToken cancellationToken)
         at Microsoft.Azure.Documents.ReplicatedResourceClient.<>c__DisplayClass30_0.<<InvokeAsync>b__0>d.MoveNext()
      --- End of stack trace from previous location ---
         at Microsoft.Azure.Documents.RequestRetryUtility.ProcessRequestAsync[TRequest,IRetriableResponse](Func`1 executeAsync, Func`1 prepareRequest, IRequestRetryPolicy`2 policy, CancellationToken cancellationToken, Func`1 inBackoffAlternateCallbackMethod, Nullable`1 minBackoffForInBackoffCallback)
         at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException)
         at Microsoft.Azure.Documents.RequestRetryUtility.ProcessRequestAsync[TRequest,IRetriableResponse](Func`1 executeAsync, Func`1 prepareRequest, IRequestRetryPolicy`2 policy, CancellationToken cancellationToken, Func`1 inBackoffAlternateCallbackMethod, Nullable`1 minBackoffForInBackoffCallback)
         at Microsoft.Azure.Documents.StoreClient.ProcessMessageAsync(DocumentServiceRequest request, CancellationToken cancellationToken, IRetryPolicy retryPolicy, Func`2 prepareRequestAsyncDelegate)         at Microsoft.Azure.Cosmos.Handlers.TransportHandler.ProcessMessageAsync(RequestMessage request, CancellationToken cancellationToken)
         at Microsoft.Azure.Cosmos.Handlers.TransportHandler.SendAsync(RequestMessage request, CancellationToken cancellationToken)
      --- Cosmos Diagnostics ---
{
  "name": "PatchItemAsync",
  "id": "916ba715-debe-46db-9b07-9b944c0c2455",
  "caller info": {
    "member": "OperationHelperWithRootTraceAsync",
    "file": "ClientContextCore.cs",
    "line": 219
  },
  "start time": "07:02:46:727",
  "duration in milliseconds": 912.0791,
  "data": {
    "Client Configuration": {
      "Client Created Time Utc": "2021-08-13T07:02:46.1909037Z",
      "NumberOfClientsCreated": 2,
      "User Agent": "cosmos-netstandard-sdk/3.20.1|3.19.3|2|X64|Microsoft Windows 10.0.22000|.NET 5.0.9|N|",
      "ConnectionConfig": {
        "gw": "(cps:50, urto:10, p:False, httpf: False)",
        "rntbd": "(cto: 5, icto: -1, mrpc: 30, mcpe: 65535, erd: False, pr: ReuseUnicastPort)",
        "other": "(ed:False, be:False)"
      },
      "ConsistencyConfig": "(consistency: NotSet, prgns:[])"
    }
  },
  "children": [
    {
      "name": "Patch Operations Serialize",
      "id": "cce0aed2-f01f-4326-a543-6ba01e260d41",
      "caller info": {
        "member": "PatchItemStreamAsync",
        "file": "ContainerCore.Items.cs",
        "line": 1254
      },
      "start time": "07:02:46:729",
      "duration in milliseconds": 6.4509
    },
    {
      "name": "Microsoft.Azure.Cosmos.Handlers.RequestInvokerHandler",
      "id": "e94f7a1f-7dd6-4406-a05b-f20abbdc5f24",
      "start time": "07:02:46:736",
      "duration in milliseconds": 901.5146,
      "children": [
        {
          "name": "Get Collection Cache",
          "id": "0fdb8026-5dbc-4906-8f77-b8f774c92c23",
          "caller info": {
            "member": "GetCollectionCacheAsync",
            "file": "DocumentClient.cs",
            "line": 546
          },
          "start time": "07:02:46:738",
          "duration in milliseconds": 0.0034
        },
        {
          "name": "Read Collection",
          "id": "c5f3f91b-9b06-42ad-902d-75d812061331",
          "caller info": {
            "member": "ReadCollectionAsync",
            "file": "ClientCollectionCache.cs",
            "line": 68
          },
          "start time": "07:02:46:752",
          "duration in milliseconds": 53.6104,
          "data": {
            "Client Side Request Stats": {
              "Id": "AggregatedClientSideRequestStatistics",
              "ContactedReplicas": [],
              "RegionsContacted": [],
              "FailedReplicas": [],
              "AddressResolutionStatistics": [],
              "StoreResponseStatistics": [],
              "HttpResponseStats": [
                {
                  "StartTimeUTC": "2021-08-13T07:02:46.8049164Z",
                  "DurationInMs": 0.0004,
                  "RequestUri": "https://xxxx-northeurope.documents.azure.com/dbs/parker-db/colls/clients",
                  "ResourceType": "Collection",
                  "HttpMethod": "GET",
                  "ActivityId": "6e67e495-fcf4-43e6-9e2d-0dd8a47168a2",
                  "StatusCode": "OK"
                }
              ]
            }
          }
        },
        {
          "name": "Microsoft.Azure.Cosmos.Handlers.DiagnosticsHandler",
          "id": "90d7fc4e-51d9-4f7e-b681-20468b0fa391",
          "start time": "07:02:46:818",
          "duration in milliseconds": 819.0157,
          "data": {
            "CPU Load History": {
              "CPU History": "(2021-08-13T07:02:45.6181990Z 50.000)"
            }
          },
          "children": [
            {
              "name": "Microsoft.Azure.Cosmos.Handlers.RetryHandler",
              "id": "b6426b90-ad48-47aa-9a87-42a1ab4f552f",
              "start time": "07:02:46:818",
              "duration in milliseconds": 819.0044,
              "children": [
                {
                  "name": "Microsoft.Azure.Cosmos.Handlers.RouterHandler",
                  "id": "7a85128a-a82a-4314-b9f6-350e8a1450bc",
                  "start time": "07:02:46:819",
                  "duration in milliseconds": 808.342,
                  "children": [
                    {
                      "name": "Microsoft.Azure.Cosmos.Handlers.TransportHandler",
                      "id": "2af79b07-f1a6-4385-bfc5-8fdf378b59db",
                      "start time": "07:02:46:819",
                      "duration in milliseconds": 808.3343,
                      "children": [
                        {
                          "name": "Microsoft.Azure.Documents.ServerStoreModel Transport Request",
                          "id": "5f1b1694-0024-4155-aefe-5b922c7237aa",
                          "caller info": {
                            "member": "ProcessMessageAsync",
                            "file": "TransportHandler.cs",
                            "line": 109
                          },
                          "start time": "07:02:46:819",
                          "duration in milliseconds": 721.2143,
                          "data": {
                            "Client Side Request Stats": {
                              "Id": "AggregatedClientSideRequestStatistics",
                              "ContactedReplicas": [
                                {
                                  "Count": 1,
                                  "Uri": "rntbd://cdb-ms-prod-northeurope1-fd45.documents.azure.com:14428/apps/6fad0193-c081-450a-901b-66645e3f2bb7/services/4022c78c-10d9-49ab-b1c2-9f78840d0156/partitions/6926c955-dd64-4048-8d0f-de760a044e23/replicas/132732738229764751s/"
                                },
                                {
                                  "Count": 1,
                                  "Uri": "rntbd://cdb-ms-prod-northeurope1-fd45.documents.azure.com:14004/apps/6fad0193-c081-450a-901b-66645e3f2bb7/services/4022c78c-10d9-49ab-b1c2-9f78840d0156/partitions/6926c955-dd64-4048-8d0f-de760a044e23/replicas/132732738229764752s/"
                                },
                                {
                                  "Count": 1,
                                  "Uri": "rntbd://cdb-ms-prod-northeurope1-fd45.documents.azure.com:14362/apps/6fad0193-c081-450a-901b-66645e3f2bb7/services/4022c78c-10d9-49ab-b1c2-9f78840d0156/partitions/6926c955-dd64-4048-8d0f-de760a044e23/replicas/132732738229764753s/"
                                }
                              ],
                              "RegionsContacted": [
                                "https://xxxx-northeurope.documents.azure.com/"
                              ],
                              "FailedReplicas": [],
                              "AddressResolutionStatistics": [
                                {
                                  "StartTimeUTC": "2021-08-13T07:02:46.9848829Z",
                                  "EndTimeUTC": "2021-08-13T07:02:47.0371388Z",
                                  "TargetEndpoint": "https://xxxx-northeurope.documents.azure.com//addresses/?$resolveFor=dbs%2fK4dvAA%3d%3d%2fcolls%2fK4dvAIClggA%3d%2fdocs&$filter=protocol eq rntbd&$partitionKeyRangeIds=0"
                                }
                              ],
                              "StoreResponseStatistics": [
                                {
                                  "ResponseTimeUTC": "2021-08-13T07:02:47.5225351Z",
                                  "ResourceType": "Document",
                                  "OperationType": "Patch",
                                  "LocationEndpoint": "https://xxxx-northeurope.documents.azure.com/",
                                  "StoreResult": {
                                    "ActivityId": "a8a9b0be-2ea9-44cd-929a-2a2a563a3ec7",
                                    "StatusCode": "StartingErrorCode",
                                    "SubStatusCode": "Unknown",
                                    "LSN": 27193,
                                    "PartitionKeyRangeId": "0",
                                    "GlobalCommittedLSN": 27193,
                                    "ItemLSN": -1,
                                    "UsingLocalLSN": false,
                                    "QuorumAckedLSN": 27193,
                                    "SessionToken": "-1#27193",
                                    "CurrentWriteQuorum": 3,
                                    "CurrentReplicaSetSize": 4,
                                    "NumberOfReadRegions": 0,
                                    "IsClientCpuOverloaded": false,
                                    "IsValid": true,
                                    "StorePhysicalAddress": "rntbd://cdb-ms-prod-northeurope1-fd45.documents.azure.com:14093/apps/6fad0193-c081-450a-901b-66645e3f2bb7/services/4022c78c-10d9-49ab-b1c2-9f78840d0156/partitions/6926c955-dd64-4048-8d0f-de760a044e23/replicas/132732738128202883p/",
                                    "RequestCharge": 1,
                                    "BELatencyInMs": "0.839",
                                    "RntbdRequestStats": [
                                      {
                                        "EventName": "Created",
                                        "StartTime": "2021-08-13T07:02:47.0560171Z",
                                        "DurationInMicroSec": "5293"
                                      },
                                      {
                                        "EventName": "ChannelAcquisitionStarted",
                                        "StartTime": "2021-08-13T07:02:47.0613108Z",
                                        "DurationInMicroSec": "349586"
                                      },
                                      {
                                        "EventName": "Pipelined",
                                        "StartTime": "2021-08-13T07:02:47.4108971Z",
                                        "DurationInMicroSec": "27616"
                                      },
                                      {
                                        "EventName": "Transit Time",
                                        "StartTime": "2021-08-13T07:02:47.4385136Z",
                                        "DurationInMicroSec": "49417"
                                      },
                                      {
                                        "EventName": "Received",
                                        "StartTime": "2021-08-13T07:02:47.4879315Z",
                                        "DurationInMicroSec": "8102"
                                      },
                                      {
                                        "EventName": "Completed",
                                        "StartTime": "2021-08-13T07:02:47.4960342Z",
                                        "DurationInMicroSec": "0"
                                      }
                                    ],
                                    "TransportException": null
                                  }
                                }
                              ],
                              "HttpResponseStats": [
                                {
                                  "StartTimeUTC": "2021-08-13T07:02:46.9057407Z",
                                  "DurationInMs": 0.0005,
                                  "RequestUri": "https://xxxx-northeurope.documents.azure.com/dbs/K4dvAA==/colls/K4dvAIClggA=/pkranges",
                                  "ResourceType": "PartitionKeyRange",
                                  "HttpMethod": "GET",
                                  "ActivityId": "aea8bef7-c8a9-495b-bfe9-2a041a5a5526",
                                  "StatusCode": "OK"
                                },
                                {
                                  "StartTimeUTC": "2021-08-13T07:02:46.9623834Z",
                                  "DurationInMs": 0.0004,
                                  "RequestUri": "https://xxxx-northeurope.documents.azure.com/dbs/K4dvAA==/colls/K4dvAIClggA=/pkranges",
                                  "ResourceType": "PartitionKeyRange",
                                  "HttpMethod": "GET",
                                  "ActivityId": "0f5577e5-015c-4302-aad4-c18c60fa2541",
                                  "StatusCode": "NotModified",
                                  "ReasonPhrase": "Not Modified"
                                },
                                {
                                  "StartTimeUTC": "2021-08-13T07:02:47.0361286Z",
                                  "DurationInMs": 0.0005,
                                  "RequestUri": "https://xxxx-northeurope.documents.azure.com//addresses/?$resolveFor=dbs%2fK4dvAA%3d%3d%2fcolls%2fK4dvAIClggA%3d%2fdocs&$filter=protocol eq rntbd&$partitionKeyRangeIds=0",
                                  "ResourceType": "Document",
                                  "HttpMethod": "GET",
                                  "ActivityId": "a8a9b0be-2ea9-44cd-929a-2a2a563a3ec7",
                                  "StatusCode": "OK"
                                }
                              ]
                            },
                            "Point Operation Statistics": {
                              "Id": "PointOperationStatistics",
                              "ActivityId": "a8a9b0be-2ea9-44cd-929a-2a2a563a3ec7",
                              "ResponseTimeUtc": "2021-08-13T07:02:47.6266761Z",
                              "StatusCode": 400,
                              "SubStatusCode": 0,
                              "RequestCharge": 1,
                              "RequestUri": "dbs/parker-db/colls/clients/docs/deee869b-4134-4546-9c96-dd06dac3acee",
                              "ErrorMessage": "Microsoft.Azure.Documents.BadRequestException: Message: {\"Errors\":[\"One of the specified inputs is invalid\"]}\r\nActivityId: a8a9b0be-2ea9-44cd-929a-2a2a563a3ec7, Request URI: /apps/6fad0193-c081-450a-901b-66645e3f2bb7/services/4022c78c-10d9-49ab-b1c2-9f78840d0156/partitions/6926c955-dd64-4048-8d0f-de760a044e23/replicas/132732738128202883p/, RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Windows/10.0.22000 cosmos-netstandard-sdk/3.19.3\r\n   at Microsoft.Azure.Documents.StoreResult.ToResponse(RequestChargeTracker requestChargeTracker)\r\n   at Microsoft.Azure.Documents.ConsistencyWriter.WritePrivateAsync(DocumentServiceRequest request, TimeoutHelper timeout, Boolean forceRefresh)\r\n   at Microsoft.Azure.Documents.BackoffRetryUtility`1.ExecuteRetryAsync(Func`1 callbackMethod, Func`3 callShouldRetry, Func`1 inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action`1 preRetryCallback)\r\n   at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException)\r\n   at Microsoft.Azure.Documents.BackoffRetryUtility`1.ExecuteRetryAsync(Func`1 callbackMethod, Func`3 callShouldRetry, Func`1 inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken, Action`1 preRetryCallback)\r\n   at Microsoft.Azure.Documents.ConsistencyWriter.WriteAsync(DocumentServiceRequest entity, TimeoutHelper timeout, Boolean forceRefresh, CancellationToken cancellationToken)\r\n   at Microsoft.Azure.Documents.ReplicatedResourceClient.<>c__DisplayClass30_0.<<InvokeAsync>b__0>d.MoveNext()\r\n--- End of stack trace from previous location ---\r\n   at Microsoft.Azure.Documents.RequestRetryUtility.ProcessRequestAsync[TRequest,IRetriableResponse](Func`1 executeAsync, Func`1 prepareRequest, IRequestRetryPolicy`2 policy, CancellationToken cancellationToken, Func`1 inBackoffAlternateCallbackMethod, Nullable`1 minBackoffForInBackoffCallback)\r\n   at Microsoft.Azure.Documents.ShouldRetryResult.ThrowIfDoneTrying(ExceptionDispatchInfo capturedException)\r\n   at Microsoft.Azure.Documents.RequestRetryUtility.ProcessRequestAsync[TRequest,IRetriableResponse](Func`1 executeAsync, Func`1 prepareRequest, IRequestRetryPolicy`2 policy, CancellationToken cancellationToken, Func`1 inBackoffAlternateCallbackMethod, Nullable`1 minBackoffForInBackoffCallback)\r\n   at Microsoft.Azure.Documents.StoreClient.ProcessMessageAsync(DocumentServiceRequest request, CancellationToken cancellationToken, IRetryPolicy retryPolicy, Func`2 prepareRequestAsyncDelegate)\r\n   at Microsoft.Azure.Cosmos.Handlers.TransportHandler.ProcessMessageAsync(RequestMessage request, CancellationToken cancellationToken)\r\n   at Microsoft.Azure.Cosmos.Handlers.TransportHandler.SendAsync(RequestMessage request, CancellationToken cancellationToken)",
                              "RequestSessionToken": null,
                              "ResponseSessionToken": "0:-1#27193",
                              "BELatencyInMs": "0.839"
                            }
                          }
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
sharan779commented, Sep 7, 2021

You will need to sign up for Patch Preview at this point. You can sign up here https://aka.ms/cosmos-partial-doc-update

Getting started Notes are https://aka.ms/cosmosdb_gettingstarted_partialdocument.

You can email cosmosdbpatchpreview@microsoft.com for any feedback or questions.

The GA for this is in a very short horizon ahead and you should hear from us in a couple of weeks.

0reactions
loraderoncommented, Dec 10, 2021

@aivsim Yes, it seems like our account can process patch requests now with both 3.21.0-preview and 3.23.0.

I do not have any additional info as to when it actually got resolved, or how.

Read more comments on GitHub >

github_iconTop Results From Across the Web

azure cosmosdb - One of the specified inputs is invalid
When trying to execute the following code I receive the following error "One of the specified inputs is invalid". Full Code public class ......
Read more >
Azure CosmosDB dotnet sdk v3 ["One of the specified inputs is ...
Azure CosmosDB dotnet sdk v3 ["One of the specified inputs is invalid"] ... Can you spot the issue? As it turns out it's...
Read more >
DocumentDb error "One of the specified inputs is invalid ...
5.2 and getting the error "One of the specified inputs is invalid". It occurs when calling CreateDocumentCollectionAsync and CreateDocumentQuery ...
Read more >
One of the specified inputs is invalid - appsloveworld.com
There are two steps to make your code working. id needs to be a string . You can change your code as @Matias...
Read more >
Getting &quot;One of the specified inputs is invalid&quot
Coding example for the question Getting "One of the specified inputs is invalid" in Azure CosmosDb PatchItemAsync.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found