Title: Adding request info does not use specified request_id for BatchRequestContent · Issue #810 · microsoftgraph/msgraph-sdk-python-core · GitHub
Open Graph Title: Adding request info does not use specified request_id for BatchRequestContent · Issue #810 · microsoftgraph/msgraph-sdk-python-core
X Title: Adding request info does not use specified request_id for BatchRequestContent · Issue #810 · microsoftgraph/msgraph-sdk-python-core
Description: Describe the bug Trying to add batch request steps with custom request IDs so that I can track the responses, however the custom request ID is always overridden to a random uuid Expected behavior Should be able to specify a custom reques...
Open Graph Description: Describe the bug Trying to add batch request steps with custom request IDs so that I can track the responses, however the custom request ID is always overridden to a random uuid Expected behavior S...
X Description: Describe the bug Trying to add batch request steps with custom request IDs so that I can track the responses, however the custom request ID is always overridden to a random uuid Expected behavior S...
Opengraph URL: https://github.com/microsoftgraph/msgraph-sdk-python-core/issues/810
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Adding request info does not use specified request_id for BatchRequestContent","articleBody":"### Describe the bug\n\nTrying to add batch request steps with custom request IDs so that I can track the responses, however the custom request ID is always overridden to a random uuid\n\n### Expected behavior\n\nShould be able to specify a custom request ID as specified in the function doc strings and in samples.\n\n### How to reproduce\n\nYou can track this through:\n\nmsgraph_core/requests/batch_request_content.py\n\n```python\n def add_request_information(\n self, request_information: RequestInformation, request_id: Optional[str] = None\n ) -\u003e None:\n \"\"\"\n Adds a request to the batch request content.\n Args:\n request_information (RequestInformation): The request information to add.\n request_id: Optional[str]: The request id to add.\n \"\"\"\n request_id = request_id if request_id else str(uuid.uuid4())\n self.add_request(request_id, BatchRequestItem(request_information))\n```\n\nWhen creating the BatchRequestItem (msgraph_core/requests/batch_request_item.py), we've not passed the request ID into the init, so a random one is assigned to the Item:\n\n```python\n def __init__(\n self,\n request_information: Optional[RequestInformation] = None,\n id: str = \"\",\n depends_on: Optional[list[Union[str, 'BatchRequestItem']]] = []\n ):\n \"\"\"\n Initializes a new instance of the BatchRequestItem class.\n Args:\n request_information (RequestInformation): The request information.\n id (str, optional): The ID of the request item. Defaults to \"\".\n depends_on (Optional[list[Union[str, BatchRequestItem]], optional):\n The IDs of the requests that this request depends on. Defaults to None.\n \"\"\"\n if request_information is None or not request_information.http_method:\n raise ValueError(\"HTTP method cannot be Null/Empty\")\n self._id = id or str(uuid4())\n```\n\nThe custom one is then only used if there isn't one already on the request, which is impossible here because of the initialisation of the item object:\n\n```python\n def add_request(self, request_id: Optional[str], request: BatchRequestItem) -\u003e None:\n \"\"\"\n Adds a request to the batch request content.\n Args:\n request_id (Optional[str]): The request id to add.\n request (BatchRequestItem): The request to add.\n \"\"\"\n if len(self.requests) \u003e= BatchRequestContent.MAX_REQUESTS:\n raise RuntimeError(f\"Maximum number of requests is {BatchRequestContent.MAX_REQUESTS}\")\n if not request.id:\n request.id = request_id if request_id else str(uuid.uuid4())\n```\n\nSo it's impossible for you to set a custom request ID through the `add_request_information` function. Either we should pass the custom one into the initialisation of the Item, or the \"add_request\" function should be checking for whether we have a `request_id` not a `request.id`. Suspect it should be the latter otherwise the function signature makes no sense.\n\n\n### SDK Version\n\n1.17.0 of the SDK, 1.20.0 of msgraph-core\n\n### Latest version known to work for scenario above?\n\n_No response_\n\n### Known Workarounds\n\n_No response_\n\n### Debug output\n\n\u003cdetails\u003e\u003csummary\u003eClick to expand log\u003c/summary\u003e\n```\n\n\u003cLog output here\u003e\n\n```\n\u003c/details\u003e\n\n\n### Configuration\n\n_No response_\n\n### Other information\n\n_No response_","author":{"url":"https://github.com/drhar","@type":"Person","name":"drhar"},"datePublished":"2025-01-23T10:39:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/810/msgraph-sdk-python-core/issues/810"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4e097687-af90-8921-c473-bd82c8b1fe25 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A054:245D90:B7EAE:F44D6:6969D2A4 |
| html-safe-nonce | 7a8dfdfd9508b946b6062a0d8ff4a61bd9f41c7243a390bcde5bc01894c557bd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDU0OjI0NUQ5MDpCN0VBRTpGNDRENjo2OTY5RDJBNCIsInZpc2l0b3JfaWQiOiIxMjUwOTIyMTQ1OTkwMTY5MjUzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 284f0688644d9ee6d260ff7b5def9d7c9bdcfbcac12e227cb72c01f392da90c3 |
| hovercard-subject-tag | issue:2806543599 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoftgraph/msgraph-sdk-python-core/810/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e67694c67011915284d5fd862bc74a133572b6f231f48401baa4b1b6e92d71c2/microsoftgraph/msgraph-sdk-python-core/issues/810 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e67694c67011915284d5fd862bc74a133572b6f231f48401baa4b1b6e92d71c2/microsoftgraph/msgraph-sdk-python-core/issues/810 |
| og:image:alt | Describe the bug Trying to add batch request steps with custom request IDs so that I can track the responses, however the custom request ID is always overridden to a random uuid Expected behavior S... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | drhar |
| hostname | github.com |
| expected-hostname | github.com |
| None | acedec8b5f975d9e3d494ddd8f949b0b8a0de59d393901e26f73df9dcba80056 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoftgraph/msgraph-sdk-python-core git https://github.com/microsoftgraph/msgraph-sdk-python-core.git |
| octolytics-dimension-user_id | 17304259 |
| octolytics-dimension-user_login | microsoftgraph |
| octolytics-dimension-repository_id | 242847794 |
| octolytics-dimension-repository_nwo | microsoftgraph/msgraph-sdk-python-core |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 242847794 |
| octolytics-dimension-repository_network_root_nwo | microsoftgraph/msgraph-sdk-python-core |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 83c08c21cdda978090dc44364b71aa5bc6dcea79 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width