Skip to content

Conversation

@leandrodamascena
Copy link
Contributor

@leandrodamascena leandrodamascena commented Nov 19, 2025

closes #187

Description of changes:

This PR improves the error message when a durable function is invoked with a non-durable payload. Previously, users would see a confusing KeyError: 'DurableExecutionArn' that didn't explain the problem or how to fix it.

Now, when the payload conversion fails, the SDK catches the error and provides a message:

ValueError: The function is not being invoked as a durable function. Please check the function configuration to ensure durability is turned on, or use the testing SDK for local testing.

Why am I using try/except?

The solution wraps the payload conversion in a try/except block that catches KeyError, TypeError, and AttributeError. I think it is more secure than checking for specific keys in the JSON because:

  • It validates the entire payload structure during conversion, not just the presence of specific keys
  • It catches any malformed or tampered payloads, including wrong data types and malformed nested structures
  • It's resilient against attempts to bypass validation by providing partial payloads with the right keys but wrong values
  • It handles edge cases that simple key checking would miss

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

@leandrodamascena leandrodamascena changed the title refactor: check if the input is a durable input refactor(sdk): make sure the input is a durable input Nov 19, 2025
@leandrodamascena leandrodamascena self-assigned this Nov 19, 2025
@leandrodamascena leandrodamascena requested a review from a user November 19, 2025 15:52
ghost
ghost previously approved these changes Nov 19, 2025
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

Copy link
Contributor Author

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

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

Hey @yaythomas thanks for the review. I left 2 comments.

@leandrodamascena leandrodamascena merged commit 43ad878 into main Nov 19, 2025
8 of 9 checks passed
@wangyb-A wangyb-A deleted the fix/deny-non-durable-payload branch December 9, 2025 22:28
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.

Improve error message when invoking durable function with non-durable payload

2 participants