first program in python fix - #487
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| raise refund_error from deposit_err | ||
|
|
||
| # Re-raise deposit error if refund was successful | ||
| raise deposit_err |
There was a problem hiding this comment.
I'm not sure on the logic here. We want to raise an error even when the refund was successful? What would the consequences of that be?
There was a problem hiding this comment.
It's the saga/compensation pattern. If the deposit permanently fails, the transfer didn't happen; the refund just undoes the withdrawal so the accounts end up consistent. Re-raising deposit_err reports that the transfer failed, even though we cleaned up.
Consequence: the Workflow ends in a Failed state and the caller gets the deposit error, so it knows the transfer didn't go through. If we didn't raise and returned success instead, the caller would think the money moved when it was actually refunded
In the Python first-program tutorial, the full workflows.py code sample near the top of the page was out of sync with the actual template repo.
Specifically, the snippet still showed: