ItemRequestOptions not flowing to custom RequestHandler RequestMessage when AllowBulkExecution is set to true
See original GitHub issueWe are continuously addressing and improving the SDK, if possible, make sure the problem persist in the latest SDK version.
Describe the bug
I’ve been trying to access the .Properties
field on the RequestMessage
in my custom type deriving from RequestHandler
after setting the ItemRequestOptions.Properties
and passing it into Container.ReadItemAsync()
but every time I would inspect the RequestMessage.Properties
field while debugging, it was empty.
I read through the source code for ReadItemAsync
and noticed we perform a different operation if BulkOperationIsSupported
. When stepping into the method called in this conditional, I saw that we cast RequestOptions
to ItemRequestOptions
here. When I attempt this cast in my own code, the result of the cast is always null
. I suspect this could be the source of the issue.
When I removed the AllowBulkExecution=true
bool from my CosmosClientOptions
setup, the RequestMessage.Properties
in my custom RequestHandler
had the properties correctly set from what I passed in from ItemRequestOptions
.
To Reproduce
- Set up
CosmosClient
and pass inCosmosClientOptions
withAllowBulkExcution
set to true. - Add a custom request handler which derives from
RequestHandler
- Add a
Container.ReadItemAsync()
method and pass in an object of typeItemRequestOptions
with any properties populated. - Put a breakpoint in the custom request handler
.SendAsync()
method. - Run the program so that it calls the
ReadItemAsync()
method. - When the breakpoint is hit in
.SendAsync()
, inspectRequestMessage.Properties
.
Expected behavior
I expected the fields from the ItemRequestOptions
passed into Container.ReadItemAsync()
to be available on the RequestMessage
in my custom RequestHandler
.
Actual behavior
None of my ItemRequestOptions
fields were being populated on the RequestMessage
when inside my custom RequestHandler.SendAsync()
method.
Environment summary SDK Version: 3.21.0 OS Version: Windows
Additional context
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
This is by design on Bulk. When Bulk mode is on, the operation does not equal the actual network request. The network request is a grouping of operations, which Properties would be sent then? An aggregation of all the Properties of all the grouped operations? What if they have Properties with the same key?
Sounds good, thanks for the info, feel free to close!