I have a document that looks something like this in CosmosDb:
{
"id": "some-value",
"cost": 20.5,
"isAvailable": false
}
When I run this query in data explorer on the portal, I get the following error:
SELECT VALUE c.isAvailable FROM c WHERE c.id = "some-value"
The error reads:
Cannot set properties of undefined (setting 'headers')
If I open the details for the error, I see:
11:27 AM Failed to query item for container MainCollection: Cannot set properties of undefined (setting 'headers')
11: 27 AM Successfully fetched 1 item for container MainCollection
Any idea why?
This is just an error in the clientside javascript rather than with the CosmosDB service itself.
It contains the following code (in FetchResult.js)
if (feedResponse) {
this.feedResponse = feedResponse;
this.fetchResultType = FetchResultType.Result;
}
else {
this.error = error;
this.fetchResultType = FetchResultType.Exception;
}
When you select a scalar value then the "feedResponse" is just that value (e.g. 20.5
for cost)
In the event "feedResponse" is the scalar value "false" or "0" this is "falsy" so it goes through to the else
branch and the result is counted as an exception rather than being just the legitimate response of the query.
The error message that is eventually returned ("Cannot set properties of undefined") is because of code that expects results of type FetchResultType.Exception
to have a not null error
object and so the following fails
fetchResult.error.headers = this._getAndResetActiveResponseHeaders();