Skip to content

fix BatchRequestItem now properly serializes the header and body fields #959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

carterm-hdc
Copy link

Overview

The batch request item serialization does not currently work for the header and body fields. For both of them, a dictionary is being passed to the write_collection_of_object_values, which is supposed to be given a list of parsable objects. An ignore type annotation is being given to silence the error.

I've replaced the method with write_additional_data_value. This method accepts a dictionary of arbitrary types, so it's able to handle the deserialized json string for the body.

Demo

Notes

The write_additional_data_value is not intended to be used in this way, and is usually used to handle excess fields that may be included in the body of a request, but are not part of the parsable model class. A dedicated method for serializing dicts is probably needed.

Testing Instructions

@carterm-hdc carterm-hdc requested a review from a team as a code owner June 18, 2025 20:12
Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

Can you add unit tests please?

Adding this test required fixing the request_info fixture and the test_initialization test because
they were using a BytesIO object when the content field should just be bytes.
Copy link

@carterm-hdc
Copy link
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants