expect a complete S3EventNotification containing the s3 create object event
package example.micronaut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification;
import io.micronaut.function.aws.MicronautRequestHandler;
import io.micronaut.serde.annotation.Serdeable;
@Serdeable
public class FunctionRequestHandler extends MicronautRequestHandler<S3EventNotification, Void> {
private static final Logger LOG = LoggerFactory.getLogger(FunctionRequestHandler.class);
@Override
public Void execute(S3EventNotification input) {
LOG.info("event: " + input);
for (S3EventNotification.S3EventNotificationRecord record : input.getRecords()) {
if (record.getEventName().contains("ObjectCreated")) {
String key = record.getS3().getObject().getKey();
LOG.info("key: " + key);
}
}
return null;
}
}
Actual Behaviour
The S3EventNotification does not contain any S3EventNotificationRecord instances, the list is null and causing a NPE
java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because the return value of "com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification.getRecords()" is null
at example.micronaut.FunctionRequestHandler.execute(FunctionRequestHandler.java:30)
at example.micronaut.FunctionRequestHandler.execute(FunctionRequestHandler.java:1)
at io.micronaut.function.aws.MicronautRequestHandler.handleRequest(MicronautRequestHandler.java:110)
Expected Behavior
expect a complete S3EventNotification containing the s3 create object event
Actual Behaviour
The S3EventNotification does not contain any S3EventNotificationRecord instances, the list is null and causing a NPE
Steps To Reproduce
use provided example from: https://guides.micronaut.io/latest/micronaut-aws-lambda-s3-event-gradle-java.html
Environment Information
Maven Java 17 and 21
Example Application
No response
Version
4.2.0