Queries not working in emulator
See original GitHub issueDescribe the bug
When I run the CosmosDb emulator for local development and attempt to query, I get this error when reading results from a query using GetItemQueryIterator
Response status code does not indicate success: 400 Substatus: 0 Reason: (Response status code does not indicate success: 400 Substatus: 0 Reason: (Gateway Failed to Retrieve Query Plan: Unknown QueryFeatures: NonValueAggregateActivityId: f2ee3729-8021-4d23-a656-33a1ab830d92, Microsoft.Azure.Documents.Common/2.5.1, Windows/10.0.18362 cosmos-netstandard-sdk/3.2.1).).
Other methods like CreateItemAsync
and ReadItemStreamAsync
work. Furthermore, this error is isolated to the emulator. If I run this code against an Azure CosmosDb, I do not get the error.
To Reproduce I have reproduced this on two machines regularly used for development with CosmosDb. We recently upgraded our .NET Framework project to use Azure Cosmos SDK v3. I was using version 2.4.5 of the emulator, and after upgrading to 2.5.6 (following steps at https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/cosmos-db/local-emulator.md#troubleshooting) the issue persisted. Here is the code that produces the error
var cosmosDb = await Storage.GetCosmosDb();
var queryDefinition = new QueryDefinition($"SELECT * FROM projects project WHERE project.organization = '{CurrentUser.Organization}'");
var queryRequestOptions = new QueryRequestOptions
{
PartitionKey = new PartitionKey(CurrentUser.Organization),
};
var projectsQuery = cosmosDb.Containers[typeof(Project)]
.GetItemQueryIterator<Project>(queryDefinition, null, queryRequestOptions);
var projects = new List<Project>();
while (projectsQuery.HasMoreResults)
{
projects.AddRange(await projectsQuery.ReadNextAsync());
}
Expected behavior
The CosmosDb emulator should work for querying locally with GetItemQueryIterator
.
Actual behavior I get an exception with the error message above.
Environment summary SDK Version: 3.2.0 OS Version; Windows 10 Home 1903
Additional context
Here’s the stack trace from the route that calls GetItemQueryIterator
:
at Microsoft.Azure.Cosmos.ResponseMessage.EnsureSuccessStatusCode()
at Microsoft.Azure.Cosmos.CosmosResponseFactory.CreateQueryFeedResponseHelper[T](ResponseMessage cosmosResponseMessage, Boolean usePropertySerializer)
at Microsoft.Azure.Cosmos.CosmosResponseFactory.CreateQueryFeedResponse[T](ResponseMessage cosmosResponseMessage)
at Microsoft.Azure.Cosmos.FeedIteratorCore`1.<ReadNextAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at DesignService.Controllers.ProjectController.<GetProjects>d__3.MoveNext() in C:\Users\scott\Documents\Paragon\ParagonCore\servers\DesignService\DesignService\Controllers\ProjectController.cs:line 131
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__1`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (7 by maintainers)
Top GitHub Comments
@sehcheese I verified that the issue is the client has new feature that the emulator doesn’t currently have. We are working on publishing a new emulator that will fix this issue.
I was able to get a repo of the issue. I’m still figuring out the root cause. You can switch your application to target x64 to get around the issue for now.