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.

Queries not working in emulator

See original GitHub issue

Describe 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:closed
  • Created 4 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
j82wcommented, Oct 1, 2019

@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.

1reaction
j82wcommented, Sep 30, 2019

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. image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chrome Emulator not activating media queries
Try using max-width. Chrome emulator shows responsive email correctly on my Chrome and I use it on all my templates.
Read more >
Android Emulator Troubleshooting - Xamarin
This article explains how to diagnose and work around problems that may occur when using the Android Emulator.
Read more >
Media Queries not working in mobile devices? - HTML & CSS
Hello everyone. I am having a problem with my portfolio website with the CSS. I have a simple media query for mobile but...
Read more >
Debug your database with the Database Inspector
To open a database in the Database Inspector, do the following: Run your app on an emulator or connected device running API level...
Read more >
Connect your app to the Cloud Firestore Emulator - Firebase
If your app attempts to interact with a resource for which an emulator isn't running, that code will fail. We recommend you use...
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