The Problem
I am using AWS cdk in Python and deploying a Docker Image on Lambda. I am new to both Docker and AWS so apologies for mistakes in advance.
Upon running my Docker Image, and sending a POST request with POSTMAN, there is no error if the data I send in the request is a JSON object. However, when I switch to form-data, no matter what input I provide, I get the error:
{
"errorMessage": "Unable to unmarshal input: Expecting value: line 1 column 1 (char 0)",
"errorType": "Runtime.UnmarshalError",
"requestId": "2b09ea5b-a99c-48ab-abcb-29c63fd5495d",
"stackTrace": []
}
I am providing the lambda_handler code, POSTMAN Screenshot and Dockerfile for reference. If anything else is needed to understand my problem better please let me know!
(Note: Dockerfile hsa stuff like mesa-libGL to handle some dependencies)
Lambda Handler Code
def lambda_handler(event, context):
return {
"statusCode": 200,
"body": "Success!"
}
Dockerfile
FROM public.ecr.aws/lambda/python:3.11
COPY requirements.txt ${LAMBDA_TASK_ROOT}
RUN pip install -r requirements.txt
RUN yum install -y mesa-libGL
COPY src/* ${LAMBDA_TASK_ROOT}
CMD [ "lambda_function.segmentation_lambda_handler" ]
POSTMAN
POSTMAN Screenshot
I tried various ways I found online to handle inputs like base64 but I can’t get rid of this error.
I have even deleted all code from my lambda_handler function and just directly returned a sample json output. Still the same error persists.
Most methods online suggest that the error arises from trying to read the value of ‘event’ directly and not converting to json or using base64.decode. I tried those with no success; moreover, I am not even using event in the code I have mentioned. I am just returning a dummy result without ever touching ‘event’. So I am clueless why the error persists.
Atharva is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.