mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(lambda): populate SQS messageAttributes in Lambda event payload (#1422)
* fix: return XML error for missing action and add volume action fallbacks * fix(eventbridge): sync EventBridge tags to ResourceGroupsTaggingService EventBridge stored tags on rules, buses, and archives in its own stores but never propagated them to the central ResourceGroupsTaggingService. This caused GetResources with --resource-type-filters events:rule to return an empty list. Inject ResourceGroupsTaggingService into EventBridgeService (following the existing GlueService pattern) and sync tags during putRule, tagResource, untagResource, and deleteRule operations. Closes #1343 * fix(lambda): populate SQS messageAttributes in Lambda event payload buildSqsEvent() was calling record.putObject("messageAttributes") which creates an empty JSON object node and discards msg.getMessageAttributes() entirely. Lambda functions receiving SQS events always saw an empty messageAttributes map regardless of what was sent with the message. Fix serializes each MessageAttributeValue into the AWS-specified shape: { dataType, stringValue, binaryValue, stringListValues, binaryListValues } Binary values are base64-encoded per the Lambda SQS event contract. md5OfMessageAttributes is now forwarded to the record when present. Added four new unit tests covering: String, Number, and Binary attribute types, multiple messages each with independent attributes, and the no-attributes case (backward compat: empty object, no md5 field). Fixes #1411 * fix: serialize only populated SQS message attribute values * fix: omit null scalar fields from SQS message attributes in Lambda event payload - Stop emitting explicit JSON nulls for absent stringValue/binaryValue fields in SqsEventSourcePoller.buildSqsEvent(); AWS Lambda omits these entirely rather than sending null. - Align serialization order with PipesPoller: check binaryValue first, then stringValue via else-if. - Update test assertions to expect key-absent (assertNull) instead of null-JSON-node (isNull) for the unpopulated scalar field.
This commit is contained in:
1 parent
e8f7cc470e
commit
a3f3bf8fe1
3 files changed
+137
-2
No files matched your search
@@ -285,8 +285,26 @@ public class SqsEventSourcePoller {
|
||||
attrs.put("SentTimestamp", String.valueOf(msg.getSentTimestamp().toEpochMilli()));
|
||||
attrs.put("SenderId", AwsArnUtils.accountOrDefault(esm.getEventSourceArn(), "000000000000"));
|
||||
attrs.put("ApproximateFirstReceiveTimestamp", String.valueOf(System.currentTimeMillis()));
|
||||
record.putObject("messageAttributes");
|
||||
// Populate messageAttributes from the message model
|
||||
ObjectNode msgAttrs = record.putObject("messageAttributes");
|
||||
if (msg.getMessageAttributes() != null) {
|
||||
msg.getMessageAttributes().forEach((name, val) -> {
|
||||
ObjectNode attrNode = msgAttrs.putObject(name);
|
||||
attrNode.put("dataType", val.getDataType() != null ? val.getDataType() : "String");
|
||||
if (val.getBinaryValue() != null) {
|
||||
attrNode.put("binaryValue",
|
||||
java.util.Base64.getEncoder().encodeToString(val.getBinaryValue()));
|
||||
} else if (val.getStringValue() != null) {
|
||||
attrNode.put("stringValue", val.getStringValue());
|
||||
}
|
||||
attrNode.putArray("stringListValues");
|
||||
attrNode.putArray("binaryListValues");
|
||||
});
|
||||
}
|
||||
record.put("md5OfBody", msg.getMd5OfBody() != null ? msg.getMd5OfBody() : "");
|
||||
if (msg.getMd5OfMessageAttributes() != null) {
|
||||
record.put("md5OfMessageAttributes", msg.getMd5OfMessageAttributes());
|
||||
}
|
||||
record.put("eventSource", "aws:sqs");
|
||||
record.put("eventSourceARN", esm.getEventSourceArn());
|
||||
record.put("awsRegion", esm.getRegion());
|
||||
|
||||
@@ -415,9 +415,10 @@ public class PipesPoller {
|
||||
for (Map.Entry<String, MessageAttributeValue> entry : msg.getMessageAttributes().entrySet()) {
|
||||
ObjectNode attrNode = msgAttrs.putObject(entry.getKey());
|
||||
MessageAttributeValue val = entry.getValue();
|
||||
attrNode.put("stringValue", val.getStringValue());
|
||||
if (val.getBinaryValue() != null) {
|
||||
attrNode.put("binaryValue", Base64.getEncoder().encodeToString(val.getBinaryValue()));
|
||||
} else if (val.getStringValue() != null) {
|
||||
attrNode.put("stringValue", val.getStringValue());
|
||||
}
|
||||
attrNode.putArray("stringListValues");
|
||||
attrNode.putArray("binaryListValues");
|
||||
|
||||
Reference in new issue
Block a user