fix(lambda): return event source mapping failure config (#1629)

Signed-off-by: Vinod Kumar <codingkiddo@gmail.com>
This commit is contained in:
Vinod Kumar Bengaluru authored and GitHub committed 2026-07-10 22:52:38 -05:00
1 parent a3e8bf5a8b
commit af0ec51f98
4 files changed
+189

No files matched your search

@@ -330,6 +330,17 @@ public class LambdaController {
node.put("State", esm.getState());
node.put("LastModified", (double) esm.getLastModified() / 1000.0);
ArrayNode responseTypes = node.putArray("FunctionResponseTypes");
if (esm.getBisectBatchOnFunctionError() != null) {
node.put("BisectBatchOnFunctionError", esm.getBisectBatchOnFunctionError());
}
if (esm.getDestinationConfig() != null && esm.getDestinationConfig().getOnFailure() != null) {
ObjectNode destinationConfig = node.putObject("DestinationConfig");
ObjectNode onFailure = destinationConfig.putObject("OnFailure");
onFailure.put("Destination", esm.getDestinationConfig().getOnFailure().getDestination());
}
if (esm.getFunctionResponseTypes() != null) {
esm.getFunctionResponseTypes().forEach(responseTypes::add);
}
@@ -709,6 +709,12 @@ public class LambdaService {
ScalingConfig scalingConfig = parseScalingConfig(request, eventSourceArn);
Boolean bisectBatchOnFunctionError = request.get("BisectBatchOnFunctionError") instanceof Boolean b
? b
: null;
EventSourceMapping.DestinationConfig destinationConfig = parseDestinationConfig(request);
String queueUrl = eventSourceArn.contains(":sqs:") ? AwsArnUtils.arnToQueueUrl(eventSourceArn, config.effectiveBaseUrl()) : null;
EventSourceMapping esm = new EventSourceMapping();
@@ -724,6 +730,8 @@ public class LambdaService {
esm.setState(enabled ? "Enabled" : "Disabled");
esm.setScalingConfig(scalingConfig);
esm.setFunctionResponseTypes(functionResponseTypes);
esm.setBisectBatchOnFunctionError(bisectBatchOnFunctionError);
esm.setDestinationConfig(destinationConfig);
esm.setLastModified(System.currentTimeMillis());
esmStore.save(esm);
@@ -734,6 +742,38 @@ public class LambdaService {
return esm;
}
private EventSourceMapping.DestinationConfig parseDestinationConfig(Map<String, Object> request) {
Object raw = request.get("DestinationConfig");
if (raw == null) {
return null;
}
if (!(raw instanceof Map<?, ?> destMap)) {
throw new AwsException("InvalidParameterValueException",
"DestinationConfig must be a JSON object", 400);
}
Object rawOnFailure = destMap.get("OnFailure");
if (rawOnFailure == null) {
return null;
}
if (!(rawOnFailure instanceof Map<?, ?> onFailureMap)) {
throw new AwsException("InvalidParameterValueException",
"DestinationConfig.OnFailure must be a JSON object", 400);
}
Object destination = onFailureMap.get("Destination");
if (destination == null) {
return null;
}
EventSourceMapping.OnFailure onFailure = new EventSourceMapping.OnFailure();
onFailure.setDestination(String.valueOf(destination));
EventSourceMapping.DestinationConfig destinationConfig = new EventSourceMapping.DestinationConfig();
destinationConfig.setOnFailure(onFailure);
return destinationConfig;
}
/**
* Parses {@code ScalingConfig} out of a create/update request and applies
* AWS-level validation: {@code MaximumConcurrency} must be in [2, 1000]
@@ -836,6 +876,15 @@ public class LambdaService {
esm.setScalingConfig(parseScalingConfig(request, esm.getEventSourceArn()));
}
if (request.containsKey("BisectBatchOnFunctionError")) {
Object raw = request.get("BisectBatchOnFunctionError");
esm.setBisectBatchOnFunctionError(raw instanceof Boolean b ? b : null);
}
if (request.containsKey("DestinationConfig")) {
esm.setDestinationConfig(parseDestinationConfig(request));
}
esm.setLastModified(System.currentTimeMillis());
esmStore.save(esm);
@@ -1,6 +1,7 @@
package io.github.hectorvent.floci.services.lambda.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
@@ -26,6 +27,8 @@ public class EventSourceMapping {
private List<String> functionResponseTypes = new ArrayList<>();
private Map<String, String> shardSequenceNumbers = new HashMap<>();
private ScalingConfig scalingConfig;
private Boolean bisectBatchOnFunctionError;
private DestinationConfig destinationConfig;
public EventSourceMapping() {
}
@@ -84,4 +87,50 @@ public class EventSourceMapping {
public Integer getMaximumConcurrency() {
return scalingConfig != null ? scalingConfig.getMaximumConcurrency() : null;
}
public Boolean getBisectBatchOnFunctionError() {
return bisectBatchOnFunctionError;
}
public void setBisectBatchOnFunctionError(Boolean bisectBatchOnFunctionError) {
this.bisectBatchOnFunctionError = bisectBatchOnFunctionError;
}
public DestinationConfig getDestinationConfig() {
return destinationConfig;
}
public void setDestinationConfig(DestinationConfig destinationConfig) {
this.destinationConfig = destinationConfig;
}
public static class DestinationConfig {
private OnFailure onFailure;
public DestinationConfig() {
}
public OnFailure getOnFailure() {
return onFailure;
}
public void setOnFailure(OnFailure onFailure) {
this.onFailure = onFailure;
}
}
public static class OnFailure {
private String destination;
public OnFailure() {
}
public String getDestination() {
return destination;
}
public void setDestination(String destination) {
this.destination = destination;
}
}
}