René's URL Explorer Experiment


Title: Incorrect Serialization Format for defaultDuration in BookingService · Issue #1262 · microsoftgraph/msgraph-sdk-python · GitHub

Open Graph Title: Incorrect Serialization Format for defaultDuration in BookingService · Issue #1262 · microsoftgraph/msgraph-sdk-python

X Title: Incorrect Serialization Format for defaultDuration in BookingService · Issue #1262 · microsoftgraph/msgraph-sdk-python

Description: Describe the bug The defaultDuration field in the BookingService model is being serialized incorrectly due to the behavior of the write_timedelta_value method in the json_serialization_writer.py module. According to the Microsoft Graph A...

Open Graph Description: Describe the bug The defaultDuration field in the BookingService model is being serialized incorrectly due to the behavior of the write_timedelta_value method in the json_serialization_writer.py mo...

X Description: Describe the bug The defaultDuration field in the BookingService model is being serialized incorrectly due to the behavior of the write_timedelta_value method in the json_serialization_writer.py mo...

Opengraph URL: https://github.com/microsoftgraph/msgraph-sdk-python/issues/1262

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect Serialization Format for defaultDuration in BookingService","articleBody":"### Describe the bug\n\nThe `defaultDuration` field in the `BookingService` model is being serialized incorrectly due to the behavior of the `write_timedelta_value` method in the `json_serialization_writer.py` module.\n\nAccording to the [Microsoft Graph API documentation for BookingService](https://learn.microsoft.com/en-us/graph/api/resources/bookingservice?view=graph-rest-1.0), the `defaultDuration` field must be serialized as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations), e.g., `P11D23H59M59.999999999999S`.\n\nHowever, the SDK currently serializes Python `timedelta` objects using the default `str(timedelta)` representation, which does not conform to ISO 8601. This results in requests being sent with incorrectly formatted durations and leading to 400 Graph API errors.\n\nRelevant Code:\n\n[File: msgraph/generated/models/booking_service.py](https://github.com/microsoftgraph/msgraph-sdk-python/blob/v1.33.0/msgraph/generated/models/booking_service.py)\n\n```python\nwriter.write_timedelta_value(\"defaultDuration\", self.default_duration)\n```\n\n[File: kiota_serialization_json/json_serialization_writer.py](https://github.com/microsoft/kiota-python/blob/main/packages/serialization/json/kiota_serialization_json/json_serialization_writer.py)\n\n```python\ndef write_timedelta_value(self, key: Optional[str], value: Optional[timedelta]) -\u003e None:\n    if isinstance(value, timedelta):\n        if key:\n            self.writer[key] = str(value)  # \u003c-- Incorrect format\n        else:\n            self.value = str(value)\n```\n\n### Expected behavior\n\n`write_timedelta_value` should serialize `timedelta` objects to valid ISO 8601 duration strings (e.g., `P1DT2H3M4S`), not the default `str(timedelta)` representation (`1 day, 2:03:04`).\n\n### How to reproduce\n\nCreate a `BookingService` object with a `default_duration = timedelta(days=1, hours=2, minutes=3, seconds=4)`.\n\nSerialize the object.\n\nObserve that the serialized value for `defaultDuration` is `\"1 day, 2:03:04\"` instead of `\"P1DT2H3M4S\"`.\n\n### SDK Version\n\n1.33.0\n\n### Latest version known to work for scenario above?\n\n_No response_\n\n### Known Workarounds\n\nCurrently manually patching the serialize method to use correct serialization\n\n```python\nfrom datetime import timedelta\n\nfrom isodate import duration_isoformat\nfrom kiota_abstractions.serialization.serialization_writer import SerializationWriter\nfrom msgraph.generated.models.booking_service import BookingService\n\n\ndef patch_booking_service(booking_service: BookingService) -\u003e None:\n    old_serializer = booking_service.serialize\n\n    def booking_service_serializer_patch(writer: SerializationWriter) -\u003e None:\n        old_serializer(writer)\n        if isinstance(booking_service.default_duration, timedelta):\n            writer.writer[\"defaultDuration\"] = duration_isoformat(booking_service.default_duration) \n\n    booking_service.serialize = booking_service_serializer_patch \n\n```\n\n### Debug output\n\n\u003cdetails\u003e\u003csummary\u003eClick to expand log\u003c/summary\u003e\n\nMainError(additional_data={}, code='UnknownError', details=None, inner_error=InnerError(additional_data={}, client_request_id='08e4b63d-43c0-42aa-a8ed-c42fc75cbf2a', date=datetime.datetime(2025, 6, 16, 20, 47, 57), odata_type=None, request_id='3e28d869-8972-4636-a6f6-6cc0a126bee5'), message='{\"type\":\"https://tools.ietf.org/html/rfc9110#section-15.5.1\",\"title\":\"One or more validation errors occurred.\",\"status\":400,\"errors\":{\"\":[\"The input was not valid.\"]},\"traceId\":\"00-3e28d86989724636a6f66cc0a126bee5-3b0ff72f47b6692f-01\"}', target=None)\n\n\n\u003c/details\u003e\n\n\n### Configuration\n\nSDK Version: Latest (as of writing)\n\nPython Version: 3.11+\n\nEndpoint: /solutions/bookingBusinesses/{id}/services\n\n### Other information\n\nProposed Fix\nAdd a new utility function for ISO 8601 serialization \nFile: `kiota_serialization_json/json_serialization_writer.py`:\n\n```python\nfrom isodate import duration_isoformat\n\ndef write_iso8601_duration(self, key: Optional[str], value: Optional[timedelta]) -\u003e None:\n    \"\"\"\n    Writes a timedelta as an ISO 8601 duration string (e.g., P1DT2H3M4S).\n    \"\"\"\n    if isinstance(value, timedelta):\n        duration = duration_isoformat(value)\n        if key:\n            self.writer[key] = duration\n        else:\n            self.value = duration\n```\n\nThen update BookingService to call this new method explicitly:\n\nFile: `msgraph/generated/models/booking_service.py`:\n\n```python\n@dataclass\nclass BookingService(Entity, Parsable):\n    ...\n    def serialize(self, writer: SerializationWriter) -\u003e None:\n        ...\n        # Use the custom method for ISO 8601 durations\n        if hasattr(writer, \"write_iso8601_duration\"):\n            writer.write_iso8601_duration(\"defaultDuration\", self.default_duration)\n        else:\n            writer.write_timedelta_value(\"defaultDuration\", self.default_duration)  # Fallback\n```","author":{"url":"https://github.com/LeoGCode","@type":"Person","name":"LeoGCode"},"datePublished":"2025-06-16T21:22:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1262/msgraph-sdk-python/issues/1262"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0a62a320-a038-0952-e104-fa087f3a4fb0
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9E12:2B5A9:1A93C:24BFC:69693E40
html-safe-nonce63bc1413a7e4facdde9927612754a5219cb63b6fa8d9781dece62943dce838e1
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RTEyOjJCNUE5OjFBOTNDOjI0QkZDOjY5NjkzRTQwIiwidmlzaXRvcl9pZCI6IjgxMTgwMjA2ODk4NDM3OTc1NjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacf80ad9400137ea88d663cff87026c0973a0330a12bcc1e64f9cfc6a3299a279e
hovercard-subject-tagissue:3151365225
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoftgraph/msgraph-sdk-python/1262/issue_layout
twitter:imagehttps://opengraph.githubassets.com/78b2bb6cccc945cea5d4e3afd65bf1adb2ce05ea535730b95f6231f623535447/microsoftgraph/msgraph-sdk-python/issues/1262
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/78b2bb6cccc945cea5d4e3afd65bf1adb2ce05ea535730b95f6231f623535447/microsoftgraph/msgraph-sdk-python/issues/1262
og:image:altDescribe the bug The defaultDuration field in the BookingService model is being serialized incorrectly due to the behavior of the write_timedelta_value method in the json_serialization_writer.py mo...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameLeoGCode
hostnamegithub.com
expected-hostnamegithub.com
None54182691a21263b584d2e600b758e081b0ff1d10ffc0d2eefa51cf754b43b51d
turbo-cache-controlno-preview
go-importgithub.com/microsoftgraph/msgraph-sdk-python git https://github.com/microsoftgraph/msgraph-sdk-python.git
octolytics-dimension-user_id17304259
octolytics-dimension-user_loginmicrosoftgraph
octolytics-dimension-repository_id534665999
octolytics-dimension-repository_nwomicrosoftgraph/msgraph-sdk-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id534665999
octolytics-dimension-repository_network_root_nwomicrosoftgraph/msgraph-sdk-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
released69ac0477df0f87da03b8b06cebd187012d7a930
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/microsoftgraph/msgraph-sdk-python/issues/1262#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2Fmsgraph-sdk-python%2Fissues%2F1262
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2Fmsgraph-sdk-python%2Fissues%2F1262
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoftgraph%2Fmsgraph-sdk-python
Reloadhttps://github.com/microsoftgraph/msgraph-sdk-python/issues/1262
Reloadhttps://github.com/microsoftgraph/msgraph-sdk-python/issues/1262
Reloadhttps://github.com/microsoftgraph/msgraph-sdk-python/issues/1262
microsoftgraph https://github.com/microsoftgraph
msgraph-sdk-pythonhttps://github.com/microsoftgraph/msgraph-sdk-python
Notifications https://github.com/login?return_to=%2Fmicrosoftgraph%2Fmsgraph-sdk-python
Fork 84 https://github.com/login?return_to=%2Fmicrosoftgraph%2Fmsgraph-sdk-python
Star 561 https://github.com/login?return_to=%2Fmicrosoftgraph%2Fmsgraph-sdk-python
Code https://github.com/microsoftgraph/msgraph-sdk-python
Issues 89 https://github.com/microsoftgraph/msgraph-sdk-python/issues
Pull requests 17 https://github.com/microsoftgraph/msgraph-sdk-python/pulls
Discussions https://github.com/microsoftgraph/msgraph-sdk-python/discussions
Actions https://github.com/microsoftgraph/msgraph-sdk-python/actions
Projects 0 https://github.com/microsoftgraph/msgraph-sdk-python/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/microsoftgraph/msgraph-sdk-python/security
Please reload this pagehttps://github.com/microsoftgraph/msgraph-sdk-python/issues/1262
Insights https://github.com/microsoftgraph/msgraph-sdk-python/pulse
Code https://github.com/microsoftgraph/msgraph-sdk-python
Issues https://github.com/microsoftgraph/msgraph-sdk-python/issues
Pull requests https://github.com/microsoftgraph/msgraph-sdk-python/pulls
Discussions https://github.com/microsoftgraph/msgraph-sdk-python/discussions
Actions https://github.com/microsoftgraph/msgraph-sdk-python/actions
Projects https://github.com/microsoftgraph/msgraph-sdk-python/projects
Security https://github.com/microsoftgraph/msgraph-sdk-python/security
Insights https://github.com/microsoftgraph/msgraph-sdk-python/pulse
New issuehttps://github.com/login?return_to=https://github.com/microsoftgraph/msgraph-sdk-python/issues/1262
New issuehttps://github.com/login?return_to=https://github.com/microsoftgraph/msgraph-sdk-python/issues/1262
Incorrect Serialization Format for defaultDuration in BookingServicehttps://github.com/microsoftgraph/msgraph-sdk-python/issues/1262#top
status:waiting-for-triageAn issue that is yet to be reviewed or assignedhttps://github.com/microsoftgraph/msgraph-sdk-python/issues?q=state%3Aopen%20label%3A%22status%3Awaiting-for-triage%22
type:bugA broken experiencehttps://github.com/microsoftgraph/msgraph-sdk-python/issues?q=state%3Aopen%20label%3A%22type%3Abug%22
https://github.com/LeoGCode
https://github.com/LeoGCode
LeoGCodehttps://github.com/LeoGCode
on Jun 16, 2025https://github.com/microsoftgraph/msgraph-sdk-python/issues/1262#issue-3151365225
Microsoft Graph API documentation for BookingServicehttps://learn.microsoft.com/en-us/graph/api/resources/bookingservice?view=graph-rest-1.0
ISO 8601 durationhttps://en.wikipedia.org/wiki/ISO_8601#Durations
File: msgraph/generated/models/booking_service.pyhttps://github.com/microsoftgraph/msgraph-sdk-python/blob/v1.33.0/msgraph/generated/models/booking_service.py
File: kiota_serialization_json/json_serialization_writer.pyhttps://github.com/microsoft/kiota-python/blob/main/packages/serialization/json/kiota_serialization_json/json_serialization_writer.py
https://tools.ietf.org/html/rfc9110#section-15.5.1","title":"Onehttps://tools.ietf.org/html/rfc9110#section-15.5.1%22,%22title%22:%22One
status:waiting-for-triageAn issue that is yet to be reviewed or assignedhttps://github.com/microsoftgraph/msgraph-sdk-python/issues?q=state%3Aopen%20label%3A%22status%3Awaiting-for-triage%22
type:bugA broken experiencehttps://github.com/microsoftgraph/msgraph-sdk-python/issues?q=state%3Aopen%20label%3A%22type%3Abug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.