mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(stepfunctions): wrap optimized lambda:invoke result in the Invoke envelope (#2165)
A Task using the arn:aws:states:::lambda:invoke integration returned the Lambda function's return value directly as the task result, with no ExecutedVersion, Payload or StatusCode key. Real Step Functions nests the function output inside the Invoke response metadata for this integration, which is why $.Payload and the JSONata $states.result.Payload are the documented ways to read a Lambda result. Against the unwrapped result those references resolved to nothing, the state still succeeded, and the execution finished SUCCEEDED carrying silently-empty data — a pipeline accumulating results across stages looked healthy while producing an empty result. Both the direct-ARN branch and the optimized branch shared one block in invokeResource(), so the parsed function output was returned raw for both. Gate the wrap to the optimized branch: it now returns ExecutedVersion (from the resolved function's version, matching what LambdaService.invoke already reports), Payload (the parsed function output) and StatusCode (from the invoke result). A directly specified function ARN keeps returning only the function output, which is the documented behavior for that form. SdkHttpMetadata and SdkResponseMetadata are deliberately not emitted. Their contents are artifacts of a real HTTPS call to the Lambda service — Date, X-Amzn-Trace-Id, RequestId, Content-Length — and floci invokes in process, so any value it put there would be invented. The .waitForTaskToken flow is unaffected: executeTaskState overwrites the task result with the callback payload, so the envelope is discarded for that pattern, as it should be. Closes #2110
This commit is contained in:
1 parent
988696b057
commit
45811768b2
2 files changed
+252
-3
No files matched your search
@@ -501,12 +501,14 @@ public class AslExecutor {
|
||||
// Support Lambda resources: direct ARN or optimized integration
|
||||
String functionName = null;
|
||||
JsonNode lambdaPayload = input;
|
||||
boolean optimizedLambdaInvoke = false;
|
||||
|
||||
if (resource.contains(":lambda:") && resource.contains(":function:")) {
|
||||
// Direct Lambda ARN: arn:aws:lambda:region:account:function:name[:qualifier]
|
||||
functionName = extractLambdaFunctionName(resource);
|
||||
} else if (resource.equals("arn:aws:states:::lambda:invoke")) {
|
||||
// Optimized Lambda integration — function name and payload come from resolved input
|
||||
optimizedLambdaInvoke = true;
|
||||
String fnRef = input.path("FunctionName").asText(null);
|
||||
if (fnRef != null) {
|
||||
functionName = extractLambdaFunctionName(fnRef);
|
||||
@@ -533,10 +535,20 @@ public class AslExecutor {
|
||||
}
|
||||
|
||||
byte[] responseBytes = result.getPayload();
|
||||
if (responseBytes != null && responseBytes.length > 0) {
|
||||
return objectMapper.readTree(responseBytes);
|
||||
JsonNode functionOutput = responseBytes != null && responseBytes.length > 0
|
||||
? objectMapper.readTree(responseBytes)
|
||||
: NullNode.getInstance();
|
||||
|
||||
// A direct function ARN yields only the function output, while the optimized
|
||||
// integration nests it in the Invoke response metadata.
|
||||
if (!optimizedLambdaInvoke) {
|
||||
return functionOutput;
|
||||
}
|
||||
return NullNode.getInstance();
|
||||
ObjectNode invokeResponse = objectMapper.createObjectNode();
|
||||
invokeResponse.put("ExecutedVersion", fn.getVersion());
|
||||
invokeResponse.set("Payload", functionOutput);
|
||||
invokeResponse.put("StatusCode", result.getStatusCode());
|
||||
return invokeResponse;
|
||||
}
|
||||
|
||||
// DynamoDB optimized integrations (4 actions)
|
||||
|
||||
Reference in new issue
Block a user