René's URL Explorer Experiment


Title: JsonDataConverter.can_reconstruct omits dict/Mapping and tuple containers, skipping type-directed input reconstruction · Issue #344 · microsoft/durabletask-python · GitHub

Open Graph Title: JsonDataConverter.can_reconstruct omits dict/Mapping and tuple containers, skipping type-directed input reconstruction · Issue #344 · microsoft/durabletask-python

X Title: JsonDataConverter.can_reconstruct omits dict/Mapping and tuple containers, skipping type-directed input reconstruction · Issue #344 · microsoft/durabletask-python

Description: Problem Description In durabletask/serialization.py, _coerce_generic() supports typed coercion for dict / Mapping and tuple containers: https://github.com/microsoft/durabletask-python/blob/06bb27763eb893693f1bc300b86a86e01a5fa641/durable...

Open Graph Description: Problem Description In durabletask/serialization.py, _coerce_generic() supports typed coercion for dict / Mapping and tuple containers: https://github.com/microsoft/durabletask-python/blob/06bb2776...

X Description: Problem Description In durabletask/serialization.py, _coerce_generic() supports typed coercion for dict / Mapping and tuple containers: https://github.com/microsoft/durabletask-python/blob/06bb2776...

Opengraph URL: https://github.com/microsoft/durabletask-python/issues/344

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"JsonDataConverter.can_reconstruct omits dict/Mapping and tuple containers, skipping type-directed input reconstruction","articleBody":"### Problem Description\n\nIn `durabletask/serialization.py`, `_coerce_generic()` supports typed coercion for `dict` / `Mapping` and `tuple` containers:\n\nhttps://github.com/microsoft/durabletask-python/blob/06bb27763eb893693f1bc300b86a86e01a5fa641/durabletask/serialization.py#L623-L645\n\n```python\n    if origin in (dict, Mapping) and isinstance(value, dict):\n        mapping = cast(\"dict[Any, Any]\", value)\n        val_type = args[1] if len(args) == 2 else None\n        if val_type is None:\n            return mapping\n        return {k: _coerce_to_type(v, val_type, converter) for k, v in mapping.items()}\n    if origin is tuple and isinstance(value, list):\n        if not args:\n            return tuple(cast(list[Any], value))\n        if len(args) == 2 and args[1] is Ellipsis:\n            return tuple(_coerce_to_type(item, args[0], converter) for item in cast(list[Any], value))\n        arr = cast(list[Any], value)\n        if len(arr) != len(args):\n            raise TypeError(\n                f\"Could not coerce JSON array of length {len(arr)} to \"\n                f\"tuple of length {len(args)}\"\n            )\n        return tuple(_coerce_to_type(item, t, converter) for item, t in zip(arr, args))\n```\n\nAnd the module documentation explicitly states:\n\n> Type-directed reconstruction recurses through dataclass fields, `list`/`Sequence`, `dict`/`Mapping` values, `tuple` elements, and `Optional` / `Union` hints.\n\nHowever, `_can_reconstruct()` only checks `Union`, `list`, `Sequence`, and `set`/`frozenset`:\n\nhttps://github.com/microsoft/durabletask-python/blob/06bb27763eb893693f1bc300b86a86e01a5fa641/durabletask/serialization.py#L280-L295\n\n```python\ndef _can_reconstruct(converter: DataConverter, target_type: Any) -> bool:\n    origin = typing.get_origin(target_type)\n    if origin is not None:\n        args = typing.get_args(target_type)\n        if origin is typing.Union or origin is types.UnionType:\n            return any(\n                converter.can_reconstruct(a) for a in args if a is not type(None)\n            )\n        if origin in (list, Sequence):\n            return any(converter.can_reconstruct(a) for a in args)\n        if origin in (set, frozenset, AbstractSet, typing.AbstractSet):\n            if not getattr(converter, \"enable_generic_sets\", False):\n                return False\n            if not args:\n                return True\n            return _is_supported_set_element(converter, args[0])\n        return False\n```\n\nIt completely omits `dict`, `Mapping`, and `tuple`.\n\nBecause `converter.can_reconstruct(dict[str, MyDataclass])` and `converter.can_reconstruct(tuple[MyDataclass, ...])` return `False`:\nIn `durabletask/internal/type_discovery.py`:\n\n```python\ndef activity_input_type(fn: Callable[..., Any], converter: DataConverter | None = None) -> type | None:\n    ...\n    return annotation if _resolve_converter(converter).can_reconstruct(annotation) else None\n```\n\nInbound type discovery drops the annotation and resolves the target type to `None`. When the worker executes the activity or orchestrator:\n\n```python\ninput_type = type_discovery.activity_input_type(fn, self._data_converter) if encoded_input else None\nactivity_input = self._data_converter.deserialize(encoded_input, input_type)\nactivity_output = fn(ctx, activity_input)\n```\n\nBecause `input_type` is `None`, the activity receives raw JSON dicts / lists instead of typed dataclass or model instances, resulting in runtime errors such as `AttributeError: 'dict' object has no attribute '...'`.\n\n---\n\n### Minimal Reproduction\n\n```python\nimport json\nfrom dataclasses import dataclass\nfrom durabletask import worker\nfrom durabletask.serialization import JsonDataConverter\nfrom durabletask.internal import type_discovery\n\n@dataclass\nclass User:\n    name: str\n\ndef process_users_activity(ctx, users: dict[str, User]):\n    for k, u in users.items():\n        assert isinstance(u, User), f\"Expected User for key {k}, got {type(u)}\"\n    return len(users)\n\nconverter = JsonDataConverter()\n\n# 1. Type discovery returns None:\ndiscovered_type = type_discovery.activity_input_type(process_users_activity, converter)\nprint(\"Discovered input type:\", discovered_type)\nassert discovered_type is None  # BUG: Expected dict[str, User]\n\n# 2. Activity invocation fails:\nreg = worker._Registry()\nact_name = reg.add_activity(process_users_activity)\nw = worker._ActivityExecutor(reg, worker.logging.getLogger(), converter)\npayload = json.dumps({\"u1\": {\"name\": \"Alice\"}})\n\ntry:\n    w.execute(\"orch-1\", act_name, 1, payload)\nexcept AssertionError as e:\n    print(\"Activity execution failed:\", e)\n```\n\nOutput:\n```\nDiscovered input type: None\nActivity execution failed: Expected User for key u1, got \u003cclass 'dict'>\n```\n\n---\n\n### Expected Behavior\n\n1. `JsonDataConverter.can_reconstruct(dict[K, V])` and `can_reconstruct(Mapping[K, V])` should return `True` when `V` is reconstructable.\n2. `JsonDataConverter.can_reconstruct(tuple[T, ...])` and `can_reconstruct(tuple[T1, T2, ...])` should return `True` when the element type(s) are reconstructable.\n3. Inbound type discovery should preserve the annotation, allowing `_coerce_generic()` to reconstruct values into their designated dataclass/model types.\n\n---\n\n### Impact\n\nUsers annotating activities or orchestrators with `dict[str, MyModel]`, `Mapping[str, MyModel]`, or `tuple[MyModel, ...]` receive uncoerced dictionaries and lists, bypassing type validation and failing at runtime during attribute access.\n\n---\n\n### Suggested Direction\n\nUpdate `_can_reconstruct()` in `durabletask/serialization.py`:\n\n```python\n        if origin in (dict, Mapping):\n            return len(args) == 2 and converter.can_reconstruct(args[1])\n        if origin is tuple:\n            if not args:\n                return False\n            if len(args) == 2 and args[1] is Ellipsis:\n                return converter.can_reconstruct(args[0])\n            return any(converter.can_reconstruct(a) for a in args)\n```\n\n---\n\ncc @andystaples @berndverst\n","author":{"url":"https://github.com/hardikkaurani","@type":"Person","name":"hardikkaurani"},"datePublished":"2026-11-05T05:19:58Z","url":"https://github.com/microsoft/durabletask-python/issues/344"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:f438b1e4-d394-d1c5-fb75-c5f8f826ebfc
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD450:306EC8:C318F9:1128644:6AFE2CE3
html-safe-nonce4909831cad5d264ec1f3a10bc1ee6ea3c4c09737fdf8a61bc8f8db2f92a1b8c8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENDUwOjMwNkVDODpDMzE4Rjk6MTEyODY0NDo2QUZFMkNFMyIsInZpc2l0b3JfaWQiOiI1NDIyNTUyNjg3MjQzNTcwNDAzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac6164b4f6a874edde14a4c066d943a00ecafa68dd271bdc5f14f4b8be5dd65f48
hovercard-subject-tagissue:6217320187
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/microsoft/durabletask-python/344/issue_layout
twitter:imagehttps://opengraph.githubassets.com/34fd7d07543694178214d57a4c5019c17d0fd16b3bb72d1c7ced3f03b91390c2/microsoft/durabletask-python/issues/344
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/34fd7d07543694178214d57a4c5019c17d0fd16b3bb72d1c7ced3f03b91390c2/microsoft/durabletask-python/issues/344
og:image:altProblem Description In durabletask/serialization.py, _coerce_generic() supports typed coercion for dict / Mapping and tuple containers: https://github.com/microsoft/durabletask-python/blob/06bb2776...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamehardikkaurani
hostnamegithub.com
expected-hostnamegithub.com
Nonee973f9ec3625f3faad8cac5c2d11a214b7ffe45f3cc563b828459b290ecaeed3
turbo-cache-controlno-preview
go-importgithub.com/microsoft/durabletask-python git https://github.com/microsoft/durabletask-python.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id627664515
octolytics-dimension-repository_nwomicrosoft/durabletask-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id627664515
octolytics-dimension-repository_network_root_nwomicrosoft/durabletask-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
release1f92c367595b9190e0be293896078033886b1913
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/durabletask-python/issues/344#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdurabletask-python%2Fissues%2F344
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdurabletask-python%2Fissues%2F344
Sign uphttps://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=microsoft%2Fdurabletask-python
Reloadhttps://github.com/microsoft/durabletask-python/issues/344
Reloadhttps://github.com/microsoft/durabletask-python/issues/344
Reloadhttps://github.com/microsoft/durabletask-python/issues/344
microsofthttps://github.com/microsoft
durabletask-pythonhttps://github.com/microsoft/durabletask-python
Codehttps://github.com/microsoft/durabletask-python
Issues15 (15)https://github.com/microsoft/durabletask-python/issues
Pull requests12 (12)https://github.com/microsoft/durabletask-python/pulls
Actionshttps://github.com/microsoft/durabletask-python/actions
Projectshttps://github.com/microsoft/durabletask-python/projects
Security and qualityhttps://github.com/microsoft/durabletask-python/security
Insightshttps://github.com/microsoft/durabletask-python/insights
https://github.com/microsoft/durabletask-python
New issuehttps://github.com/login?return_to=https://github.com/microsoft/durabletask-python/issues/344
New issuehttps://github.com/login?return_to=https://github.com/microsoft/durabletask-python/issues/344
#346https://github.com/microsoft/durabletask-python/pull/346
JsonDataConverter.can_reconstruct omits dict/Mapping and tuple containers, skipping type-directed input reconstructionhttps://github.com/microsoft/durabletask-python/issues/344#top
#346https://github.com/microsoft/durabletask-python/pull/346
https://github.com/hardikkaurani
Hardik K (hardikkaurani)https://github.com/hardikkaurani
on Nov 5, 2026https://github.com/microsoft/durabletask-python/issues/344#issue-6217320187
https://github.com/microsoft/durabletask-python/blob/06bb27763eb893693f1bc300b86a86e01a5fa641/durabletask/serialization.py#L623-L645https://github.com/microsoft/durabletask-python/blob/06bb27763eb893693f1bc300b86a86e01a5fa641/durabletask/serialization.py#L623-L645
https://github.com/microsoft/durabletask-python/blob/06bb27763eb893693f1bc300b86a86e01a5fa641/durabletask/serialization.py#L280-L295https://github.com/microsoft/durabletask-python/blob/06bb27763eb893693f1bc300b86a86e01a5fa641/durabletask/serialization.py#L280-L295
andystapleshttps://github.com/andystaples
Bernd Verst (@berndverst)https://github.com/berndverst
Bernd Verst (berndverst)https://github.com/berndverst
completedhttps://github.com/microsoft/durabletask-python/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#346https://github.com/microsoft/durabletask-python/pull/346
on Nov 10, 2026https://github.com/microsoft/durabletask-python/issues/344#event-35633945177
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/durabletask-python/issues/344
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/durabletask-python/issues/344
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.