0

I've created a function in an AWS lambda that invokes a second lambda function using a LambdaCall.

public InvokeResult invokeResponse() {
InvokeResult invokeResult = lambdaCall.invokeLambda(invokeRequestParameters.getFunctionName(), invokeRequestParameters.getPayload());
return invokeResult;
}

The payload is a string "Version". In the second lambda, the handleRequest code contains is:

public String handleRequest(InputStream inputStream, Context context) {
    ObjectMapper mapper = new ObjectMapper();
    try {

    String text = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n"));
        if (text.equals("\"Version\"")) {
            VersionResponse versionResponse = getVersion();
            return mapper.writeValueAsString(versionResponse);
        }
    return null;
    } catch (Exception error) {
        LOGGER.info(error);
        return null;
    }

VersionResponse is a simple POJO and I've confirmed that getVersion is returning the VersionResponse object. Currently the Lambda is retrieving the "Version String" and getVersion is working fine. However, when the string is returned the InvokeResult has a null payload. Any idea what I'm doing wrong?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Hywel Griffiths
  • 287
  • 5
  • 16
  • Is the call being invoked as `RequestResponse`? That is the default, so I wouldn't expect that to be your issue, but if you set it to `Event` you would not get a payload in the result. – Jason Wadsworth Dec 08 '20 at 22:18
  • Currently using InvokeRequest invokeRequest = (new InvokeRequest()).withFunctionName(functionName).withPayload("\"" + lambdaPayload + "\"").withInvocationType(InvocationType.RequestResponse); so its a RequestResponse type :-/ – Hywel Griffiths Dec 09 '20 at 10:28

1 Answers1

1

This happened to me (in NodeJS) because in an lambda using an async function I forgot to add a return resultValue to return the right value, so the lambda didn't have a good value to return, and used null as return value. I think this could happend too if in a lambda using callback parameter you forget to call callback(null, result)