Skip to content
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

Decorating a event function may cause unexpected errors #2217

Open
mlubimow opened this issue May 5, 2021 · 0 comments
Open

Decorating a event function may cause unexpected errors #2217

mlubimow opened this issue May 5, 2021 · 0 comments

Comments

@mlubimow
Copy link

mlubimow commented May 5, 2021

Context

It's not technically a bug, but current behaviour of a mechanism to run a scheduled function just doesn't seem to be correct. Adding a very subtle, safe looking change can cause scheduled events to fail.

Expected Behavior

Event functions should be required to accept kwargs

Actual Behavior

Params passed to functions are different depending if it has varargs or not

Possible Fix

Make "function" in events deprecated, replace it with "handler" or some other key and add checks to ensure that function is correct.

Steps to Reproduce

  1. Create a event function:
def some_task():
   # do something
   return True
  1. Add it to events in zappa_settings.json
"events": [
     {
         "function": "my_tasks.some_task",
         "expression": "cron(0 1 * * ? *)"
     }
]
  1. One day someone adds a generic decorator:
def generic_decorator(func):
   @wraps(func)
   def wrapper(*args, **kwargs):
       # do something
       return func(*args, **kwargs)
   return wrapper

@generic_decorator
def some_task():
   # do something
   return True
  1. Task fails at night. event and context variables get passed to some_task, but it doesn't accept any arguments. Works like a charm in unit tests.

Your Environment

n/a

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

No branches or pull requests

1 participant