aws / chalice

Python Serverless Microframework for AWS
Apache License 2.0
10.61k stars 1.01k forks source link

HandlerNotFound Error After Moving Lambda Function to Module in Chalice #2114

Open ArKhachatryan opened 2 months ago

ArKhachatryan commented 2 months ago

I have a Lambda function deployed with Chalice that is triggered by an SQS queue event. After refactoring my code to move the function from the main app.py file to a module and registering the module via a blueprint, I started receiving the following error:

[ERROR] Runtime.HandlerNotFound: Handler 'any_handler' missing on module 'app'
Traceback (most recent call last):

api.py

from chalice import Blueprint

api = Blueprint(__name__)

@api.on_sqs_message(
    queue='queue_name',
    batch_size=1
)
def any_handler(event):
    # Function logic here

app.py:


from chalice import Chalice
from chalicelib.api import api, handle_http_errors

app = Chalice(app_name='app_name')

app.api.binary_types = ['application/x-protobuf']
app.register_blueprint(api)

app.register_middleware(handle_http_errors, 'http')

Chalice version: 1.31.0