Azure / azure-cosmos-dotnet-v2

Contains samples and utilities relating to the Azure Cosmos DB .NET SDK
MIT License
577 stars 836 forks source link

Invalid API version #744

Open ChangeTheCode opened 5 years ago

ChangeTheCode commented 5 years ago

Describe the bug I am using on the build server the cosmosdb emulator version 2.7.0.0. In the code I am using the nuget package version 2.4.2 and I also tried to use the version 2.8.1. Both version throw this error during execution of integration tests. I tried to run the build multiple time and like i mentioned I change the version of the nuget package.

This error occurred after I did a update of the nuget package from version 1.18.0. I tried to find a solution to pass the information about the version via the sdk but I cloudn't find something.

I think this issue is related to the #380 - this issue is closed but this issue is still occurring.

Error Build server throw this error during executing of "unit" test. System.AggregateException: One or more errors occurred. ---> Microsoft.Azure.Documents.DocumentClientException: Invalid API version. Ensure a valid x-ms-version header value is passed. Please update to the latest version of Azure Cosmos DB SDK. ActivityId: a41f7ec2-c2bd-4f35-82be-b8d149b2ae9a, Microsoft.Azure.Documents.Common/2.0.0.0, documentdb-dotnet-sdk/2.4.2 Host/64-bit MicrosoftWindowsNT/10.0.14393.0

Environment summary

SDK Version: Windows 10

Stack trace

at Microsoft.Azure.Documents.GatewayStoreClient.<ParseResponseAsync>d__8.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at System.Runtime.CompilerServices.TaskAwaiter'1.GetResult() at Microsoft.Azure.Documents.Client.GatewayServiceConfigurationReader.<GetDatabaseAccountAsync>d__43.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at System.Runtime.CompilerServices.TaskAwaiter'1.GetResult() at Microsoft.Azure.Documents.Routing.GlobalEndpointManager.<GetDatabaseAccountFromAnyLocationsAsync>d__16.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at System.Runtime.CompilerServices.TaskAwaiter'1.GetResult() at Microsoft.Azure.Documents.Client.GatewayServiceConfigurationReader.<InitializeReaderAsync>d__45.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at System.Runtime.CompilerServices.TaskAwaiter'1.GetResult() at Microsoft.Azure.Documents.Client.DocumentClient.<InitializeGatewayConfigurationReader>d__330.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Microsoft.Azure.Documents.Client.DocumentClient.<GetInitializationTask>d__93.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Microsoft.Azure.Documents.Client.DocumentClient.<EnsureValidClientAsync>d__146.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Microsoft.Azure.Documents.Client.DocumentClient.<GetCollectionCacheAsync>d__78.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at System.Runtime.CompilerServices.TaskAwaiter'1.GetResult() at Microsoft.Azure.Documents.Query.DocumentQueryClient.<Microsoft-Azure-Documents-Query-IDocumentQueryClient-GetCollectionCacheAsync>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Syste

foo-baar commented 4 years ago

Wondering why no follow up on this issue yet ? I am also facing the same behavior.

j82w commented 4 years ago

@foo-baar are you running against the local emulator? If so can you please upgrade to the latest emulator.

j82w commented 4 years ago

@bchong95 any suggestions?

foo-baar commented 4 years ago

Hi @j82w I am using dotnet core 2.2 and writing an API project, hence connecting to Cosmos fails at : await _documentClient.CreateDatabaseIfNotExistsAsync(new Database { Id = databaseId });

Posted issue to a friend here : https://github.com/nhandrew/cosmosdbrestapi/issues/1

j82w commented 4 years ago

Can you try .NET SDK 2.9.2 and the latest emulator 2.7.2? Does it work if you run against actual Cosmos DB instead of the emulator? I'm trying to determine if this is a comparability issue.

foo-baar commented 4 years ago

Hi @j82w "I'm trying to determine if this is a comparability issue." I don't think so, since mine a straight http call to the CosmosDb.

bchong95 commented 4 years ago

Please use fiddler to show us the raw HTTP request for better debugging. Specifically we are interested in the value of the "x-ms-version" header.

ChangeTheCode commented 4 years ago

I did what you described about fiddler and I saw the sdk is sending still the latest version to the cosmos emulator. Also the implementation shows I take Everytime the latest version. And I could not find a solution to override the header.

j82w commented 4 years ago

@ChangeTheCode what is the value of the "x-ms-version" in the header?