Skip to content

Fix durabletask issues surfaced during Azure Functions investigation#174

Merged
andystaples merged 2 commits into
microsoft:mainfrom
andystaples:andystaples/durabletask-fixes-from-functions-investigation
Jul 14, 2026
Merged

Fix durabletask issues surfaced during Azure Functions investigation#174
andystaples merged 2 commits into
microsoft:mainfrom
andystaples:andystaples/durabletask-fixes-from-functions-investigation

Conversation

@andystaples

Copy link
Copy Markdown
Contributor

Summary

While building out Azure Functions support, several pre-existing issues in the core durabletask SDK were surfaced. This PR splits those fixes out into a dedicated, self-contained change so they can be reviewed independently of the larger Functions work.

Fixes (durabletask/worker.py)

  • Timer timezone bug — Timers created with a timezone-aware fire_at were compared against the orchestration's naive UTC clock, which could cause them to fire at the wrong time. Timezone-aware fire times are now normalized to naive UTC before scheduling.
  • Orchestration version presence check — Replaced a truthiness check on executionStarted.version with HasField("version"). A singular protobuf message field is always truthy, so the version was being set on OrchestrationContext even when none was provided.
  • genericEvent handling — Replaying a genericEvent history event (for example, the marker the Durable Functions extension appends when rewinding an orchestration) raised OrchestrationStateError. Such informational events are now ignored during replay, matching the .NET worker.
  • Lock-granted entity events — Over the legacy entity protocol, a lock-granted response attempted to deserialize an empty operation result and raised. Lock-granted events no longer attempt result deserialization.

Additions

  • Task.result — New read-only property aliasing Task.get_result() (durabletask/task.py).
  • bind_context / clear_context — Now exported from durabletask.extensions.history_export for managing the ambient history-export context.

Serialization robustness (default wire format unchanged)

  • ScheduleState.from_json gains an optional converter parameter plus a _rebuild_configuration helper so the nested ScheduleConfiguration round-trips under alternate converters (durabletask/scheduled/models.py).
  • ScheduleOperationRequest gains explicit to_json / from_json hooks, mirroring the plain dataclass field mapping so the wire format is unchanged for the default JSON converter while remaining serializable by converters that require an explicit hook (durabletask/scheduled/orchestrator.py).

Validation

  • Pylance clean; flake8 clean on all changed files.
  • CHANGELOG.md updated with ADDED / FIXED entries for the user-facing changes.
  • Full core test suite: 734 passed, 9 skipped.

Copilot AI review requested due to automatic review settings July 14, 2026 17:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes several correctness issues in the core durabletask worker that were surfaced while investigating Azure Functions support, and adds a couple of small API/serialization improvements to improve interoperability with alternate JSON converters.

Changes:

  • Fixed multiple replay/runtime edge cases in durabletask/worker.py (timer timezone normalization, orchestration version presence check, ignore genericEvent during replay, and avoid deserializing empty lock-grant results in the legacy entity protocol).
  • Added a Task.result read-only property as an alias for Task.get_result().
  • Improved scheduled-entity JSON round-tripping under non-default converters (explicit hooks and converter-aware rebuild logic), and exported ambient history-export context helpers.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
durabletask/worker.py Fixes replay/runtime bugs (timers, version presence, generic events, legacy entity lock results).
durabletask/task.py Adds Task.result property aliasing get_result().
durabletask/scheduled/orchestrator.py Adds explicit to_json/from_json hooks for ScheduleOperationRequest to support converters that can’t serialize bare dataclasses.
durabletask/scheduled/models.py Makes ScheduleState.from_json converter-aware and adds a helper to reliably rebuild nested ScheduleConfiguration.
durabletask/extensions/history_export/init.py Re-exports bind_context / clear_context in the public module surface.
CHANGELOG.md Documents user-facing additions and fixes under ## Unreleased.

Comment thread durabletask/worker.py
berndverst
berndverst previously approved these changes Jul 14, 2026
@andystaples andystaples merged commit 5722cd4 into microsoft:main Jul 14, 2026
17 checks passed
@andystaples andystaples deleted the andystaples/durabletask-fixes-from-functions-investigation branch July 14, 2026 18:32
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.

3 participants