-
Notifications
You must be signed in to change notification settings - Fork 4.5k
(custom-resources): Provider function is throwing "Error: return values from user-handlers must be JSON objects. got: "" #26429
Description
Describe the bug
Hello team,
I am seeing the error Error: return values from user-handlers must be JSON objects. got: "" recently while using the Provider construct of aws-cdk-lib/custom-resources. Checking the cloudwatch logs of the request, I see that this is the return value sent back from the oneventhandler lambda fn.
{
$metadata: {
httpStatusCode: 200,
requestId: 'xxxx',
attempts: 1,
totalRetryDelay: 0
},
ExecutedVersion: '$LATEST',
Payload: {},
StatusCode: 200
}
I see that there was a change recently in parseJsonPayload function from const text = payload.toString(); to let text = new TextDecoder().decode(Buffer.from(payload));.
Expected Behavior
Provider fn to return empty values/success
Current Behavior
Provider function is throwing "Error: return values from user-handlers must be JSON objects. got: ""
Reproduction Steps
Not sure of the reproduction steps here. Although I do not see any return from the event lambda.
This works fine if the return logged is "" like
{
$metadata: {
httpStatusCode: 200,
requestId: 'xxxx',
attempts: 1,
totalRetryDelay: 0
},
ExecutedVersion: '$LATEST',
Payload: "",
StatusCode: 200
}
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.87.0
Framework Version
No response
Node.js Version
18.16
OS
mac
Language
Typescript
Language Version
No response
Other information
No response