feat(firehose): apply the Lambda transform to buffered records (#3393)

* feat(firehose): apply the Lambda transform to buffered records

A flushed buffer now goes to the Lambda processor's function as a single
invocation, and what the function returns is what reaches the destination.
Ok delivers the returned data, Dropped leaves no trace, and every other
outcome routes that record to the error output while the rest of the batch
still delivers: ProcessingFailed, a record the function did not return, a
record id returned twice, and an Ok carrying no data.

A function-level error is retried NumberOfRetries more times and then fails
the whole batch as Lambda.FunctionError; a response the function returned
successfully is final however malformed it is, matching what AWS reports for
a response naming no records at all.

The transformation runs ahead of data format conversion, so a stream
configured for both converts what the function returned, and the
"not applied yet" warning the configuration used to log is gone.

* fix(firehose): clamp a NumberOfRetries wider than a long, and heal a stored Enabled

Long.parseLong threw for a NumberOfRetries too wide for a long, which the
catch treated as "not a number" and answered with the default 3. A larger
retry count than one that clamps therefore got fewer attempts: 2147483648
delivered 101 attempts where 999999999999999999999 delivered 4. Reading it
as a BigInteger keeps the clamp meaningful at any magnitude.

A ProcessingConfiguration persisted before Enabled was defaulted never
passes canonicalizeProcessors again, so the describe path now fills it, the
way that path already self-heals partial BufferingHints. Only Enabled: the
parameters AWS defaults include RoleArn, which a read must not inject from
whatever role is current by then.
This commit is contained in:
Kenshin Okinaka authored and GitHub committed 2026-09-11 11:45:03 -04:00
1 parent c6e64a0977
commit d96516dc70
11 files changed
+1628 -38

No files matched your search

@@ -0,0 +1,388 @@
package io.github.hectorvent.floci.services.firehose;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.core.common.AwsArnUtils;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription;
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.Processor;
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.ProcessorParameter;
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.S3Destination;
import io.github.hectorvent.floci.services.lambda.LambdaService;
import io.github.hectorvent.floci.services.lambda.model.InvocationType;
import io.github.hectorvent.floci.services.lambda.model.InvokeResult;
import io.github.hectorvent.floci.services.s3.S3Service;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
import java.io.ByteArrayOutputStream;
import java.math.BigInteger;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
/**
* Runs a flushed batch through the stream's Lambda transform before it is
* delivered: one invocation per batch carrying every buffered record, the
* returned data replacing the original, and records the function dropped or
* failed taken out of the delivery. The failed ones go to the error output,
* one NDJSON line each, under the evaluated ErrorOutputPrefix with
* {@code !{firehose:error-output-type}} resolved to {@code processing-failed}.
*
* The per-record semantics were probed against real AWS (us-west-2,
* 2026-09-10): {@code Ok} delivers the returned data, {@code Dropped} leaves no
* trace at all, and anything else routes that record to the error output while
* the rest of the batch still delivers. A function that errors is retried, a
* response the function shaped wrongly is not. Every message below is AWS's own
* except the two {@code Lambda.InvalidReturnFormat} ones this class invents, for
* a {@code result} AWS does not define and for {@code data} that is not base64.
*
* This runs ahead of data format conversion, so a stream with both configured
* converts what the transform returned.
*/
@ApplicationScoped
public class FirehoseLambdaTransformer {
private static final Logger LOG = Logger.getLogger(FirehoseLambdaTransformer.class);
private static final String ERROR_OUTPUT_TYPE = "processing-failed";
private static final String CONTENT_TYPE = "application/octet-stream";
private static final int DEFAULT_NUMBER_OF_RETRIES = 3;
private static final int MAX_NUMBER_OF_RETRIES = 100;
private static final String RESULT_OK = "Ok";
private static final String RESULT_DROPPED = "Dropped";
private static final String RESULT_PROCESSING_FAILED = "ProcessingFailed";
private static final String FUNCTION_ERROR_MESSAGE =
"The Lambda function was successfully invoked but it returned an error result.";
private static final String MISSING_RECORD_ID_MESSAGE =
"One or more record Ids were not returned. Ensure that the Lambda function returns"
+ " all received record Ids.";
private static final String DUPLICATED_RECORD_ID_MESSAGE =
"Multiple records were returned with the same record Id. Ensure that the Lambda"
+ " function returns a unique record Id for each record.";
private static final String PROCESSING_FAILED_MESSAGE = "ProcessingFailed status set for record";
private static final String NULL_DATA_MESSAGE =
"The data field cannot be null when the SourceType is DirectPut or KinesisStreamAsSource"
+ " and processing result is Ok. The value field cannot be null when the SourceType"
+ " is MSKAsSource and processing result is Ok.";
private final LambdaService lambdaService;
private final S3Service s3Service;
private final ObjectMapper mapper;
private final RegionResolver regionResolver;
@Inject
public FirehoseLambdaTransformer(LambdaService lambdaService, S3Service s3Service,
ObjectMapper mapper, RegionResolver regionResolver) {
this.lambdaService = lambdaService;
this.s3Service = s3Service;
this.mapper = mapper;
this.regionResolver = regionResolver;
}
/** What a transformation produced: the records still to deliver, plus the counts for the flush log line. */
public record Outcome(List<byte[]> records, int droppedRecords, int failedRecords, String errorKey) {}
public Outcome transform(DeliveryStreamDescription stream, String bucket, List<byte[]> records,
Instant deliveryTime) {
S3Destination s3 = stream.s3Destination();
Processor processor = lambdaProcessor(s3);
if (processor == null) {
return new Outcome(records, 0, 0, null);
}
String functionArn = parameterValue(processor, "LambdaArn");
List<String> recordIds = new ArrayList<>(records.size());
for (int i = 0; i < records.size(); i++) {
recordIds.add(UUID.randomUUID().toString());
}
Invocation invocation = invoke(stream, functionArn, recordIds, records, deliveryTime,
numberOfRetries(processor) + 1);
List<byte[]> delivered = new ArrayList<>(records.size());
List<FailedRecord> failures = new ArrayList<>();
int dropped = 0;
for (int i = 0; i < records.size(); i++) {
byte[] record = records.get(i);
Verdict verdict = invocation.verdictFor(recordIds.get(i));
if (verdict.errorCode() != null) {
failures.add(new FailedRecord(record, verdict.errorCode(), verdict.errorMessage()));
} else if (verdict.data() == null) {
dropped++;
} else {
delivered.add(verdict.data());
}
}
String errorKey = failures.isEmpty() ? null
: writeErrorOutput(stream, s3, bucket, failures, deliveryTime, functionArn,
invocation.attemptsMade());
return new Outcome(delivered, dropped, failures.size(), errorKey);
}
// ── configuration ────────────────────────────────────────────────────────
/**
* The single Lambda processor of an enabled ProcessingConfiguration, or null when the
* stream has none: the other processor types AWS models are stored and echoed but not
* applied. The validator has already made "at most one" true.
*/
private static Processor lambdaProcessor(S3Destination s3) {
if (s3 == null || !s3.isProcessingEnabled() || s3.getProcessingConfiguration().getProcessors() == null) {
return null;
}
for (Processor processor : s3.getProcessingConfiguration().getProcessors()) {
if (processor != null && "Lambda".equals(processor.getType())
&& parameterValue(processor, "LambdaArn") != null) {
return processor;
}
}
return null;
}
/**
* AWS does not range-check NumberOfRetries at configuration time, so a stored value
* can be any number the parameter's string type allows, 2147483647 included. It is
* clamped rather than honored: a flush occupies the single flusher thread, so a retry
* count that large would stall every other stream's delivery behind it. The cap is
* well above the documented 1 to 8 and the 9 the probe saw honored. A value that is
* not a number falls back to the 3 AWS itself defaults to.
*
* Read as a BigInteger so the clamp holds at any magnitude: a value too wide even for
* a long is still a number, and treating it as unparseable would hand a larger
* NumberOfRetries fewer attempts than a smaller one.
*/
private static int numberOfRetries(Processor processor) {
String configured = parameterValue(processor, "NumberOfRetries");
if (configured == null) {
return DEFAULT_NUMBER_OF_RETRIES;
}
try {
return new BigInteger(configured.trim())
.max(BigInteger.ZERO)
.min(BigInteger.valueOf(MAX_NUMBER_OF_RETRIES))
.intValue();
} catch (NumberFormatException e) {
LOG.warnv("Firehose Lambda processor has a non-numeric NumberOfRetries {0}, using {1}",
configured, DEFAULT_NUMBER_OF_RETRIES);
return DEFAULT_NUMBER_OF_RETRIES;
}
}
private static String parameterValue(Processor processor, String name) {
if (processor.getParameters() == null) {
return null;
}
for (ProcessorParameter parameter : processor.getParameters()) {
if (parameter != null && name.equals(parameter.getParameterName())) {
return parameter.getParameterValue();
}
}
return null;
}
// ── invocation ───────────────────────────────────────────────────────────
/**
* What one batch's invocation settled on: either a function-level failure every
* record inherits, or the per-record results the function returned.
*/
private record Invocation(int attemptsMade, boolean functionError,
Map<String, LambdaResult> results, Set<String> duplicatedIds) {
Verdict verdictFor(String recordId) {
if (functionError) {
return Verdict.failed("Lambda.FunctionError", FUNCTION_ERROR_MESSAGE);
}
if (duplicatedIds.contains(recordId)) {
return Verdict.failed("Lambda.DuplicatedRecordId", DUPLICATED_RECORD_ID_MESSAGE);
}
LambdaResult result = results.get(recordId);
if (result == null) {
return Verdict.failed("Lambda.MissingRecordId", MISSING_RECORD_ID_MESSAGE);
}
if (RESULT_DROPPED.equals(result.result())) {
return Verdict.dropped();
}
if (RESULT_PROCESSING_FAILED.equals(result.result())) {
return Verdict.failed("Lambda.ProcessingFailedStatus", PROCESSING_FAILED_MESSAGE);
}
if (!RESULT_OK.equals(result.result())) {
return Verdict.failed("Lambda.InvalidReturnFormat",
"The result field must be one of Ok, Dropped or ProcessingFailed.");
}
if (result.data() == null) {
return Verdict.failed("Lambda.InvalidReturnFormat", NULL_DATA_MESSAGE);
}
try {
return Verdict.transformed(Base64.getDecoder().decode(result.data()));
} catch (IllegalArgumentException e) {
return Verdict.failed("Lambda.InvalidReturnFormat",
"The data field must be base64 encoded: " + e.getMessage());
}
}
}
private record LambdaResult(String result, String data) {}
/** A transformed payload, a failure, or, with every member null, a drop. */
private record Verdict(byte[] data, String errorCode, String errorMessage) {
static Verdict transformed(byte[] data) {
return new Verdict(data, null, null);
}
static Verdict dropped() {
return new Verdict(null, null, null);
}
static Verdict failed(String errorCode, String errorMessage) {
return new Verdict(null, errorCode, errorMessage);
}
}
/**
* Invokes the function, retrying only a function-level error: a response the
* function returned successfully is taken as final however malformed it is (probed,
* a response with no records at all reports attemptsMade 1 while a throwing
* function reports NumberOfRetries + 1).
*/
private Invocation invoke(DeliveryStreamDescription stream, String functionArn, List<String> recordIds,
List<byte[]> records, Instant deliveryTime, int maxAttempts) {
byte[] payload = buildPayload(stream, recordIds, records, deliveryTime);
for (int attempt = 1; attempt <= maxAttempts; attempt++) {
try {
InvokeResult result = lambdaService.invokeArn(functionArn, payload, InvocationType.RequestResponse);
if (result.getFunctionError() == null) {
return parseResponse(attempt, result.getPayload());
}
LOG.warnv("Firehose transform {0} returned {1} on attempt {2} of {3}",
functionArn, result.getFunctionError(), attempt, maxAttempts);
} catch (Exception e) {
LOG.warnv("Firehose transform {0} could not be invoked on attempt {1} of {2}: {3}",
functionArn, attempt, maxAttempts, e.getMessage());
}
}
return new Invocation(maxAttempts, true, Map.of(), Set.of());
}
private byte[] buildPayload(DeliveryStreamDescription stream, List<String> recordIds,
List<byte[]> records, Instant deliveryTime) {
Map<String, Object> event = new LinkedHashMap<>();
event.put("invocationId", UUID.randomUUID().toString());
event.put("deliveryStreamArn", stream.getDeliveryStreamARN());
event.put("region", AwsArnUtils.regionOrDefault(stream.getDeliveryStreamARN(),
regionResolver.getDefaultRegion()));
List<Map<String, Object>> eventRecords = new ArrayList<>(records.size());
for (int i = 0; i < records.size(); i++) {
Map<String, Object> eventRecord = new LinkedHashMap<>();
eventRecord.put("recordId", recordIds.get(i));
// Floci does not track per-record arrival, so the batch's delivery time stands
// in for all of them, as it does in the error output.
eventRecord.put("approximateArrivalTimestamp", deliveryTime.toEpochMilli());
eventRecord.put("data", Base64.getEncoder().encodeToString(records.get(i)));
eventRecords.add(eventRecord);
}
event.put("records", eventRecords);
try {
return mapper.writeValueAsBytes(event);
} catch (Exception e) {
throw new AwsException("InternalServerException",
"Failed to serialize a Firehose transformation payload: " + e.getMessage(), 500);
}
}
/**
* A response that carries no usable records array leaves every record unaccounted
* for, which is what AWS reports for it: Lambda.MissingRecordId per record rather
* than a batch-level failure (probed). An entry naming a record the batch never
* contained is ignored, also as AWS does.
*/
private Invocation parseResponse(int attempt, byte[] responsePayload) {
Map<String, LambdaResult> results = new LinkedHashMap<>();
Set<String> duplicatedIds = new HashSet<>();
JsonNode records = readRecords(responsePayload);
if (records != null) {
for (JsonNode record : records) {
String recordId = text(record, "recordId");
if (recordId == null) {
continue;
}
LambdaResult result = new LambdaResult(text(record, "result"), text(record, "data"));
if (results.putIfAbsent(recordId, result) != null) {
duplicatedIds.add(recordId);
}
}
}
return new Invocation(attempt, false, results, duplicatedIds);
}
private JsonNode readRecords(byte[] responsePayload) {
if (responsePayload == null || responsePayload.length == 0) {
return null;
}
try {
JsonNode response = mapper.readTree(responsePayload);
JsonNode records = response == null ? null : response.get("records");
return records != null && records.isArray() ? records : null;
} catch (Exception e) {
LOG.warnv("Firehose transform returned a response that is not JSON: {0}", e.getMessage());
return null;
}
}
private static String text(JsonNode node, String field) {
JsonNode value = node.get(field);
return value == null || !value.isTextual() ? null : value.asText();
}
// ── error output ─────────────────────────────────────────────────────────
private record FailedRecord(byte[] data, String errorCode, String errorMessage) {}
/**
* One NDJSON line per failed record, in the shape and member order real AWS writes
* (probed). It is not the format-conversion error object: that one leads with
* attemptsMade and carries lastErrorCode and a dataCatalogTable block, where this
* one leads with rawData and ends with lambdaARN, in that casing.
*
* Both timestamps are the delivery time, a deviation: Floci tracks no per-record
* arrival. attemptsMade counts the batch's attempts, a record never having retries
* of its own.
*/
private String writeErrorOutput(DeliveryStreamDescription stream, S3Destination s3, String bucket,
List<FailedRecord> failures, Instant deliveryTime,
String functionArn, int attemptsMade) {
String errorKey = S3ObjectKeyResolver.resolveErrorKey(s3, stream.getDeliveryStreamName(),
stream.getVersionId(), deliveryTime, ERROR_OUTPUT_TYPE);
ByteArrayOutputStream body = new ByteArrayOutputStream();
for (FailedRecord failure : failures) {
Map<String, Object> line = new LinkedHashMap<>();
line.put("rawData", Base64.getEncoder().encodeToString(failure.data()));
line.put("errorCode", failure.errorCode());
line.put("errorMessage", failure.errorMessage());
line.put("attemptsMade", attemptsMade);
line.put("arrivalTimestamp", deliveryTime.toEpochMilli());
line.put("attemptEndingTimestamp", deliveryTime.toEpochMilli());
line.put("lambdaARN", functionArn);
try {
body.write(mapper.writeValueAsBytes(line));
body.write('\n');
} catch (Exception e) {
throw new AwsException("InternalServerException",
"Failed to serialize a Firehose error-output record: " + e.getMessage(), 500);
}
}
s3Service.putObject(bucket, errorKey, body.toByteArray(), CONTENT_TYPE, Map.of());
return errorKey;
}
}
@@ -102,6 +102,7 @@ public class FirehoseService implements ResourceProvider {
// commits exactly the position that snapshot covered.
private final Map<String, Map<String, String>> pendingSourceIterators = new ConcurrentHashMap<>();
private final FirehoseParquetConverter parquetConverter;
private final FirehoseLambdaTransformer lambdaTransformer;
private final Clock clock;
private final long tickIntervalSeconds;
private final int flushRecordCount;
@@ -187,7 +188,8 @@ public class FirehoseService implements ResourceProvider {
@Inject
public FirehoseService(StorageFactory storageFactory, S3Service s3Service, KinesisService kinesisService,
RegionResolver regionResolver, Clock clock, EmulatorConfig config,
FirehoseParquetConverter parquetConverter) {
FirehoseParquetConverter parquetConverter,
FirehoseLambdaTransformer lambdaTransformer) {
this.streamStore = storageFactory.create("firehose", "streams.json",
new TypeReference<Map<String, DeliveryStreamDescription>>() {});
this.sourceIteratorStore = storageFactory.create("firehose", "source-iterators.json",
@@ -196,6 +198,7 @@ public class FirehoseService implements ResourceProvider {
this.kinesisService = kinesisService;
this.regionResolver = regionResolver;
this.parquetConverter = parquetConverter;
this.lambdaTransformer = lambdaTransformer;
this.clock = clock;
this.tickIntervalSeconds = Math.max(1, config.services().firehose().tickIntervalSeconds());
this.flushRecordCount = Math.max(0, config.services().firehose().flushRecordCount());
@@ -313,7 +316,6 @@ public class FirehoseService implements ResourceProvider {
if (s3Config != null) {
s3Config.canonicalizeProcessors();
}
warnIfProcessingEnabled(name, s3Config);
String arn = AwsArnUtils.Arn.of("firehose", region, accountId,
"deliverystream/" + name).toString();
// CreateDeliveryStream's KinesisStreamSourceConfiguration carries only the ARN and
@@ -392,7 +394,6 @@ public class FirehoseService implements ResourceProvider {
stream.setLastUpdateTimestamp(java.time.Instant.now());
streamPut(streamKey, stream);
LOG.infov("Updated destination {0} of Firehose delivery stream {1}", destinationId, name);
warnIfProcessingEnabled(name, stream.s3Destination());
}
public void startDeliveryStreamEncryption(String name, String keyType, String keyArn) {
@@ -464,20 +465,6 @@ public class FirehoseService implements ResourceProvider {
}
}
/**
* Says, where the configuration is set, that the transformation will not be applied.
* Fires on create and on every update that leaves it enabled, so a caller who keeps
* changing the destination keeps being told. Deliberately not in the flush path,
* which runs on every buffered delivery: create and update are caller-driven and are
* the moments a caller can act on the warning.
*/
private static void warnIfProcessingEnabled(String name, S3Destination s3) {
if (s3 != null && s3.isProcessingEnabled()) {
LOG.warnv("Delivery stream {0} enables a record transformation, which Floci does not"
+ " apply yet; its records will be delivered untransformed", name);
}
}
private static void mergeDestination(S3Destination current, S3Destination update) {
if (update.getRoleArn() != null) current.setRoleArn(update.getRoleArn());
if (update.getBucketArn() != null) current.setBucketArn(update.getBucketArn());
@@ -893,10 +880,26 @@ public class FirehoseService implements ResourceProvider {
try {
String bucket = resolveBucket(stream);
S3Destination s3 = stream.s3Destination();
List<byte[]> records = toFlush;
if (s3 != null && s3.isProcessingEnabled()) {
ensureBucket(bucket);
FirehoseLambdaTransformer.Outcome transformed =
lambdaTransformer.transform(stream, bucket, records, clock.instant());
LOG.infov("Transformed {0} records from stream {1} ({2} dropped, {3} failed)",
records.size(), streamName, transformed.droppedRecords(), transformed.failedRecords());
records = transformed.records();
if (records.isEmpty()) {
// Nothing survived the transform. The batch is accounted for, dropped
// records deliberately leaving no trace and failed ones already in the
// error output, so the source may advance past it.
commitSourceIterators(streamName, checkpoint);
return;
}
}
if (s3 != null && s3.isDataFormatConversionEnabled()) {
ensureBucket(bucket);
FirehoseParquetConverter.Outcome outcome =
parquetConverter.deliver(stream, bucket, toFlush, clock.instant());
parquetConverter.deliver(stream, bucket, records, clock.instant());
LOG.infov("Converted {0} records ({1} failed) from stream {2} to s3://{3}/{4}",
outcome.convertedRecords(), outcome.failedRecords(), streamName, bucket,
outcome.dataKey() != null ? outcome.dataKey() : outcome.errorKey());
@@ -917,7 +920,7 @@ public class FirehoseService implements ResourceProvider {
// (verified: three "abc" records arrive as the 9 bytes "abcabcabc").
// See the deviation noted in docs/services/firehose.md.
ByteArrayOutputStream payload = new ByteArrayOutputStream();
for (byte[] data : toFlush) {
for (byte[] data : records) {
payload.writeBytes(data);
if (data.length > 0 && data[data.length - 1] != '\n') {
payload.write('\n');
@@ -928,7 +931,7 @@ public class FirehoseService implements ResourceProvider {
s3Service.putObject(bucket, key, body, "application/octet-stream", Map.of(),
new PutObjectOptions().withContentEncoding(compression.contentEncoding()));
LOG.infov("Flushed {0} records from stream {1} to s3://{2}/{3} ({4})",
toFlush.size(), streamName, bucket, key, compression.wireValue());
records.size(), streamName, bucket, key, compression.wireValue());
// Only now: the records these iterators were read past are durable.
commitSourceIterators(streamName, checkpoint);
} catch (Exception e) {
@@ -263,17 +263,18 @@ public class DeliveryStreamDescription {
}
/**
* True when a transformation applies to deliveries. An omitted Enabled is taken
* as enabled, following the conversion block, where that was probed; the
* processing block's own behavior for an omitted Enabled was not, and nothing
* but the "not applied yet" warning reads this today.
* True when a transformation applies to deliveries: the configuration is present
* and Enabled is explicitly true. An omitted Enabled leaves it disabled, the
* opposite of the conversion block below. Probed rather than carried over from
* there (2026-09-11): DescribeDeliveryStream echoes an omitted Enabled as false
* here and as true on the conversion block.
*
* Ignored for serialization for the same reason as the accessor below.
*/
@JsonIgnore
public boolean isProcessingEnabled() {
return processingConfiguration != null
&& !Boolean.FALSE.equals(processingConfiguration.getEnabled());
&& Boolean.TRUE.equals(processingConfiguration.getEnabled());
}
/**
@@ -326,13 +327,25 @@ public class DeliveryStreamDescription {
bufferingHints.setIntervalInSeconds(BufferingHints.DEFAULT_INTERVAL_SECONDS);
}
}
// Legacy persisted state again: a processing block stored before Enabled was
// defaulted never passes canonicalizeProcessors a second time, and would be
// described without the member AWS always returns. Only Enabled is healed
// here, since the parameters AWS defaults include RoleArn, which a read must
// not inject from whatever role is current by then.
if (processingConfiguration != null && processingConfiguration.getEnabled() == null) {
processingConfiguration.setEnabled(false);
}
}
/**
* Real AWS answers with more than the caller sent: a Lambda processor comes back
* with NumberOfRetries defaulted to 3 and RoleArn filled from the delivery
* stream's role, and the parameters are echoed in a fixed order whatever order
* they arrived in (probed 2026-09-10).
* with NumberOfRetries defaulted to 3, RoleArn filled from the delivery stream's
* role, and BufferSizeInMBs and BufferIntervalInSeconds defaulted to 1 and 60,
* and the parameters are echoed in a fixed order whatever order they arrived in
* (probed 2026-09-10 and 2026-09-11). The two buffer defaults are the Lambda
* processor's own, not the destination's BufferingHints: a destination buffering
* 5 MiB over 300s still echoes 1 and 60 here. An omitted Enabled is stored as
* false, which is what leaves the transformation disabled.
*
* Called as a destination is written, not as it is read. Doing it on the way out
* would mutate what storage handed back, so whether a Describe had happened would
@@ -340,7 +353,13 @@ public class DeliveryStreamDescription {
* role was current at the time of the read.
*/
public void canonicalizeProcessors() {
if (processingConfiguration == null || processingConfiguration.getProcessors() == null) {
if (processingConfiguration == null) {
return;
}
if (processingConfiguration.getEnabled() == null) {
processingConfiguration.setEnabled(false);
}
if (processingConfiguration.getProcessors() == null) {
return;
}
for (Processor processor : processingConfiguration.getProcessors()) {
@@ -360,6 +379,8 @@ public class DeliveryStreamDescription {
if (roleArn != null) {
byName.putIfAbsent("RoleArn", roleArn);
}
byName.putIfAbsent("BufferSizeInMBs", "1");
byName.putIfAbsent("BufferIntervalInSeconds", "60");
List<ProcessorParameter> ordered = new ArrayList<>(byName.size());
for (String name : LAMBDA_PARAMETER_ORDER) {
if (byName.containsKey(name)) {