I want to get my Parameter at state_handler, It is...
# prefect-community
I want to get my Parameter at state_handler, It is OK on local test. But it have error on prefect server like this:
Exception raised while calling state handlers: KeyError(<Parameter: fisrt_num>,)
how can i solve this problem? Here is my code
Copy code
def add(x, y):
    return x+y

def post_to_slack(task, old_state, new_state):
    if new_state.is_failed():
        msg = "Task {0} finished in state {1}".format(task, new_state)
    if new_state.is_finished():
        p = new_state.result[num].result
    return new_state

with Flow("Tutorial", state_handlers=[post_to_slack]) as flow:
    x = Parameter("fisrt_num")
    y = Parameter("Second_num")

    num = add(x,y)
Hi @philip - there are a few things: - your flow doesn’t have any tasks in it; you probably intended to add those Parameters to your Flow but you didn’t. This is a common confusion - checkout GitHub for solutions - I don’t recommend referencing
within your State Handler; this relies on the statehandler being run in the same process that you created
and could lead to unexpected errors
Thank you, I edited some my code. This is an example, I want to use state handler to check if the process finished, i can print some log or send email. Can i referencing like
in handler?