Search code examples
pythonamazon-web-servicesaws-lambdahandler

Python handler error - not enough values to unpack


I have the following python function:

def evaluate_conditions(context, event):
    sqs_count = sqs_msg_count()
    sqs_average = int(os.environ["AVG_QUEUE_SIZE"])
    ec2_count = running_instance_count()
    ec2_average = int(os.environ["AVG_NR_OF_EC2_SCAN_SERVERS"])
    
    print(f"Number of EC2 instances is {ec2_count}")
    print(f"Queue size is {sqs_count}")   
    
    if sqs_count > sqs_average and ec2_count > ec2_average:
        print("False alert, queue is above the average queue size, but enough ec2 instances are running")
        logger.info()
    elif sqs_count < sqs_average and ec2_count < ec2_average:
        print("False alert, queue is below the average queue size")
        # logger.info()
    elif sqs_count < sqs_average and ec2_count > ec2_average:
        print("False alert, queue is below the queue average, and there are enough ec2 instances running")
        logger.info()
    else:
        sns_client.publish(
            TopicArn=os.environ["SNS_ARN"],
            Message="Sample",
            Subject="Monitoring",
        )
        print("Published to SNS Topic")

After i redeployed the function in aws lambda using serverless i now get the following error

{
  "errorMessage": "Bad handler 'function.name/evaluate_conditions': not enough values to unpack (expected 2, got 1)",
  "errorType": "Runtime.MalformedHandlerName",
  "stackTrace": []
}

But after the redeploy the exact same function was correctly working. The handler is defined in aws lambda is "function.name/evaluate_conditions"

How can i fix this?


Solution

  • found the error, correct handler name is "function.name/handler.evaluate_conditions