I can't find callback parameter in python lambda handler
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Python AWS Lambda handlers do not use a callback parameter like older Node.js Lambda examples. In Python, the runtime calls your handler with only event and context, and success or failure is represented by your return value or by an exception.
Use the Correct Python Handler Signature
The standard Python Lambda handler signature is:
There is no third callback argument. If you define handler(event, context, callback), the Lambda runtime will not invoke it correctly.
This is the root of the confusion for many developers who have copied patterns from Node.js tutorials.
Return Values Replace Callback Success
In callback-driven runtimes, success is often signaled by calling the callback with a result. In Python, you simply return the result.
If the function is behind API Gateway or a Function URL, that dictionary becomes the HTTP-style response.
Raise Exceptions or Map Errors Explicitly
Failures are represented by raised exceptions or by explicit error responses, depending on the event source and the style you want.
That is the Python replacement for “call callback with an error.”
Why Tutorials Mention Callback at All
Older AWS Lambda examples for Node.js often showed a callback parameter. That pattern belongs to the Node.js runtime model, not the Python runtime model.
A useful mental separation is:
- older Node.js examples often used
callback - Python uses
returnandraise
Once you keep those runtimes separate, the missing callback stops being mysterious.
Async Workflows Use AWS Services, Not a Callback Parameter
If what you really want is deferred or asynchronous behavior, the answer is not a Python callback argument. The answer is usually an AWS async pattern such as:
- asynchronous Lambda invocation
- SQS or SNS fan-out
- EventBridge routing
- Step Functions orchestration
That gives you callback-like architecture behavior without changing the handler signature.
Match the Return Shape to the Trigger Type
Not every Lambda trigger expects an API Gateway-style dictionary. SQS, EventBridge, and many other event sources ignore statusCode and body completely. The correct return format depends on the trigger.
So the real rule is:
- Python handlers always accept
eventandcontext - the returned payload shape depends on the invoking service
That distinction matters more than the absence of a callback.
Common Pitfalls
- Defining a Python Lambda handler with a third callback parameter.
- Copying Node.js Lambda examples into Python without changing the execution model.
- Returning API Gateway-style responses for triggers that do not care about them.
- Treating asynchronous workflow design as if it should come from a handler callback.
- Using broad exception handling without clear error mapping for the real caller.
Summary
- Python Lambda handlers take only
eventandcontext. - Success is represented by a return value, not by invoking a callback.
- Failures are represented by exceptions or explicit error responses.
- Callback-based examples usually come from older Node.js Lambda patterns.
- For deferred workflows, use AWS async services rather than trying to add a Python callback parameter.
Related reading
- I can't run more than 5 tasks in AWS ECS Fargate
- I need an Amazon S3 user with full access to a single bucket
- I want to use boto3 in async function, python
- iCloud basics and code sample
- I can't install python-ldap
- I get error module 'tensorflow.keras.layers' has no attribute 'Normalization
- If rabbitmq can''t be used as a locking service, then what can?
- Implementation of Atomic Transactions in dynamodb

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.