-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Computation of idempotency hash key using unqualified name #1330
Comments
Thanks for flagging this @dispyfree - we indeed use qualified name elsewhere in the code but not in the idempotency. According to the PEP 3155, it excludes the module name so the result would be the same regardless of how it was imported. Would you like to send a fix as a first contributor? Alternatively, we can also fix it ourselves and give you credit as always. Thank you! |
Assigning to me so I can push a fix and make a patch release tomorrow |
That's an interesting bit @heitorlessa.
By excluding the module, however, we can - in theory - still have two distinct functions contest for the same idempotency items. They just bear the same name, have the same parameters and sit in two modules. Even then I am not sure whether this will then cover all conceivable cases; but at least I can't think of another way to break this off the top of my head :) Btw. avid users of AWS Powertools speaking here - we have fixed the scale-in problem in user code and I hope I'll be able to feed that back into the upstream project. |
Hello @dispyfree ! Reading your last message, I think it makes a lot of sense to add I reproduced here and if we replace I created 2 scenarios to simulate the two situations 1 - Replacing Unexpected result 2 - Replacing name with Main code and modtest code remain the same Expected result I'm also not 100% sure if this covers all scenarios, but I don't see any other way this could give a problem setting the qualified name and module name. @heitorlessa I also believe that this will generate a small load for customers who already have the idempotency records generated, because as the key will change, all records will need to be generated again. But I don't see a way to do this without any kind of "impact". I hope this debug helps in some way to have a definition about this. Thank you. |
Thank you both, that's super helpful. I agree in including the module as that will cover cases where people use the new typing.Protocol as well as traditional ABC interfaces. @dispyfree would you like to do the honour and contribute the fix today? We want to make a release today with this fix. PS: @dispyfree I'm stoked you're an avid customer. I'd love to hear more from you one of these days ❤️ |
@heitorlessa I'd be pleased to contribute. Feel free to assign to me; I shall have a go at it in the coming days :) |
Awesome. I've had a discussion with @rubenfonseca on the impact this breaking change could have given the change of keys. We assessed that it might impact over a million functions, since it'll invalidate an hour worth of transactions (default) or more (custom TTL). We came to the conclusion that there are two ways we could proceed:
If you agree, let's go with 1 for now, and we can release this sooner than v2. Otherwise, we can do with 2, and update the documentation with a warning beforehand. Please do shout out to @rubenfonseca @leandrodamascena or myself if you get stuck with writing tests for Idempotency - it's the most complex to write and we want to move away from the stubber approach soon. |
Hi @dispyfree we're actively prioritizing on this so we could include it as a breaking change for our v2 release. Do you still have the bandwidth to finish it? |
Hi @rubenfonseca |
Hi @dispyfree, don't worry! We know that everyone is very busy and sometimes 24 hours a day is not enough. I'll finish this and ping you to take a look before we merge, ok? |
Hi @dispyfree. We are about to merge this PR, do you want to take a look before merging this? In fact, this is a huge improvement (and bug fix) that we will be releasing in v2. PR link: #1535 Thank you |
Closing as we're wrap to launch V2 |
|
Expected Behaviour
The idempotency layer should be using the fully qualified name of the input function to compute the hash key.
Using unqualified names may result in two distinct functions and/or methods contending for the same set of idempotency items.
Current Behaviour
In IdempotencyHandler, line 77:
persistence_store.configure(config, self.function.__name__)
Possible Solution
persistence_store.configure(config, self.function.__qualname__)
Note that it should be checked whether
__qualname__
is subject to Python module import peculiarities. In particular, whetherimport module
andfrom module import funcName
yield the same__qualname__
.Steps to Reproduce
AWS Lambda Powertools for Python version
latest
AWS Lambda function runtime
3.9
Packaging format used
PyPi
Debugging logs
No response
The text was updated successfully, but these errors were encountered: