Skip to content

Conversation

@ConnorKirk
Copy link
Contributor

@ConnorKirk ConnorKirk commented Dec 2, 2025

Issue number: fixes #7762

Summary

This PR adds support for durable functions in the Idempotency utility.

  1. Introduce the is_replay variable. We use this to determine if a function is being replayed.
  2. Correctly register the lambda context when a durable context is passed.

Changes

Please provide a summary of what's being changed

  • Add is_replay parameter to the handle method
  • If there's an existing idempotency record, but the function is a replay, then allow the function to continue
  • Add a stubbed DurableContext class
  • Add tests

User experience

Idempotency utility now allows durable functions to execute after suspension.

Notes

This leaves one issue remaining in the idempotency utility when used with durable functions.

We use context.getTimeInMillis() to calculate the expiry time of the INPROGRESS status. Duplicate payloads received after that expiry time will be allowed. In a durable execution, the length of the workflow can be up to 1 year, across multiple lambda invocations. This is longer than the maximum 15 minutes that an INPROGRESS status can currently have. Idempotency records for long running workflows will not be protected from duplicate invokes beyond the first 15 minutes of their life.

In future, we could

  1. Push for the inclusion of the DurableContext.getExecutionTimeoutInMillis() method. Once this is added, we can calculate the workflow timeout in the same manner we do for a single invocation.
  2. Allow the user to configure a timeout. We'd direct users to set this to match their durable execution timeout. I'm reluctant to add a new configuation option to the Handler/Config, especially if it might be redundant in the medium term (see Feature: Integrate custom metrics with new CloudWatch embedded metric #1)
  3. Retrieve the durable execution configuration within the function and set the timeout. This appears simpler, but requires an additional IAM permission, and might be surprising for a user.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

Durable Functions introduces the concept of function replays.
Previously, the idempotency utility would throw an
"IdempotencyItemAlreadyExistsError", as the replay has the same payload
of the initial execution. It appears as a duplicate, so is rejected.
Now, a replay is allowed
@ConnorKirk ConnorKirk requested a review from a team as a code owner December 2, 2025 18:11
@ConnorKirk ConnorKirk requested a review from sdangol December 2, 2025 18:11
@boring-cyborg boring-cyborg bot added tests typing Static typing definition related issues (mypy, pyright, etc.) labels Dec 2, 2025
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 2, 2025
@ConnorKirk ConnorKirk changed the title Feat/df idempotency feat(idempotency): Allow durable functions to replay Dec 2, 2025
@github-actions github-actions bot added the feature New feature or functionality label Dec 2, 2025
@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.52%. Comparing base (0dbac63) to head (9cf394b).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #7764   +/-   ##
========================================
  Coverage    96.52%   96.52%           
========================================
  Files          275      275           
  Lines        13123    13139   +16     
  Branches       990      992    +2     
========================================
+ Hits         12667    12683   +16     
  Misses         353      353           
  Partials       103      103           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 2, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or functionality size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests typing Static typing definition related issues (mypy, pyright, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: add support for durable function in Idempotency Utility

2 participants