Open achard opened 3 years ago
The KeyError
when deploying also happened to me (locally it works fine). I saw your issue (@achard) and went to change my set comprehensions and it worked again. In my case it was enough to change the braces to set()
.
Before:
access_plan_ids = {access.plan_id for access in accesses}
After:
access_plan_ids = set(access.plan_id for access in accesses)
I recently faced the same problem with Chalice version 1.27.3
. Changing from set comprehension to the set()
function worked out, i.e.
this does not work:
# app.py
{item['value'] for item in collection}
while this works:
# app.py
set(item['value'] for item in collection)
I believe this is due to the policy generation procedure. You can reproduce the problem if you just call chalice gen-policy
without necessarily calling chalice deploy
.
I'm getting a key error when attempting to deploy my code.
I have isolated the issue to one of the functions, it seems to me that Chalice may not be able to understand set comprehensions? My code works fine when running locally. It deploys fine when I comment out the function/route in question.
The line that seems to be causing my issues it this one:
dynamodb_address_set |= {address_object['address'] for address_object in response.get('Items', [])}
I was able to work around this issue by replacing that line with these two:
The full function causing the error is:
And the traceback I get when attempting to deploy is this: